junit5 註解

/** * @Test(timeout=1000) * @Test(except=RuntimeException.class) * @Tag * @ExtendWith * @TestFactory * @TestInstance * @TestTemplate * @EnabledOnOs * @EnabledOnJre * @EnabledIfSystemProperty * @BeforeEach * @AfterEach * @Disabled * @Nested * @RepeatedTest * @ParameterizedTest * @EnumSource * @MethodSource * @ArgumentSource * @ValueSource(ints = {2, 4, 8}) * @CsvSource({"1,One", "2,Two", "3,Three"}) * Assumptions * Assertions */ @SpringBootTest @ActiveProfiles("dev") @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @DisplayName("用戶賬號測試") @Transactional class UserIdentifyDaoTest { @Autowired private UserIdentifyDao userIdentifyDao; static UserIdentifyDO userIdentifyDO; @BeforeAll static void init() { userIdentifyDO = new UserIdentifyDO(); userIdentifyDO.setId(Identifys.build(UserIdentifyDO.class).get()); userIdentifyDO.setIdentify(UUID.randomUUID().toString()); userIdentifyDO.setType(1); userIdentifyDO.setUserInfoId(2L); userIdentifyDO.setCreateTime(new Date()); } @BeforeEach void beforeEach() { this.userIdentifyDao.save(userIdentifyDO); } @Test @DisplayName("添加") @Order(1) void addTest() { //success } @Test @DisplayName("修改") @Rollback(false) @Order(2) void update() { userIdentifyDO.setIdentify(UUID.randomUUID().toString()); this.userIdentifyDao.save(userIdentifyDO); } @Test @DisplayName("刪除") @Order(3) void delete() { //success } @Test @DisplayName("主鍵查詢") @Order(4) void findById() { Optional<UserIdentifyDO> byId = this.userIdentifyDao.findById(userIdentifyDO.getId()); Assertions.assertTrue(byId.isPresent()); System.out.println(byId.get()); } @AfterEach @Transactional @Rollback(false) void afterEach() { this.userIdentifyDao.deleteById(userIdentifyDO.getId()); } }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章