반응형

@Test 어노테이션으로 테스트 메소드라는것을 선언한다.

@BeforeEach 테스트 실행전 작업


Test fixture 테스트를 반복적으로 수행할 수 있게 도와주고 매번 동일한 결과를 얻을 수 있게 도와주는 상태나 환경,  (test context)



java8 junit5로 작업중이다.

보고 있는책은 junit4다.

버전이 다르니 쓰이는어노테이션도 다르다.


Annotations

Features

JUnit 5

JUnit 4

Declares a test method@Test@Test
Denotes that the annotated method will be executed before all test methods  in the current class@BeforeAll@BeforeClass
Denotes that the annotated method will be executed after all test methods  in the current class@AfterAll@AfterClass
Denotes that the annotated method will be executed before each test method@BeforeEach@Before
Denotes that the annotated method will be executed after each test method@AfterEach@After
Disable a test method or a test class@Disable@Ignore
Denotes a method is a test factory for dynamic tests in JUnit 5@TestFactoryN/A
Denotes that the annotated class is a nested, non-static test class@NestedN/A
Declare tags for filtering tests@Tag@Category
Register custom extensions in JUnit 5@ExtendWithN/A
Repeated Tests in JUnit 5@RepeatedTestN/A

Assertions.

JUnit 4

JUnit 5

failfail
assertTrueassertTrue
assertThatN/A
assertSameassertSame
assertNullassertNull
assertNotSameassertNotSame
assertNotEqualsassertNotEquals
assertNotNullassertNotNull
assertFalseassertFalse
assertEqualsassertEquals
assertArrayEqualsassertArrayEquals
assertAll
assertThrows

출처 : https://howtoprogram.xyz/2016/08/10/junit-5-vs-junit-4/



현제 필요한 기능이 아니면 절대로 미리 만들지 말자.

여유가 된다면 변화에 민첩하게 대응가능하게 리팩토링 하자.

반응형

+ Recent posts