JUnit4 JUnit5
JUnit4 JUnit5
JUnit4에서 JUnit5으로 넘어오며 변경된 점 요약
- 자바 버전 5 → 8 이상
- 1개의 jar → Junit Platform, Junit Jupiter, Junit Vintage 세 개의 모듈로 구성
- @Before, @After → @BeforeEach, @AfterEach
- @BeforeClass, @AfterClass → @BeforeAll, @AfterAll
- @RunWith(SpringRunner.class) → @ExtendWith(SpringExtension.class)
- @Category → @Tag
- @Rule, @ClassRule → @ExtendWith, @RegisterExtention
- Assertion의 위치가 org.junit.jupiter.api.Assertions로 변경
- Spring boot 2.2 부터 기본으로 Junit 5 제공
References
- https://jade314.tistory.com/entry/Junit-5
- https://hirlawldo.tistory.com/39
- https://velog.io/@minky/Junit5-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0