1. JUnit 이란?
-. Java 및 JVM을 위한 프로그래머 친화적인 테스트 프레임워크
-. 오픈소스 단위테스트 도구
2. JUnit의 등장
-. 이전 개발 테스트는 main method에 production Code와 TestCode가 혼재하여 작성하였다.
-. 이러한 개발 테스트의 문제는 ⓐ클래스 규모가 커져 복잡도 증가 ⓑ운영소스에 테스트코드 존재 ⓒSystem.out이나 소요시간을 수동으로 출력 및 결과 확인 ⓓ불분명한 테스트 의도 및 이력 관리 등이 있다.
-. 위 문제들을 해결하기 위한 도구로 JUnit 탄생
3. JUnit5
-. 모던 자바의 최신기술(람다,스트림 등)에 맞춰 구성
-. JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage
-. JUnit Platform serves as a foundation for launching testing frameworks on the JVM
-. JUnit Jupiter is the combination of the new programming model and extension model for writing tests and extensions in JUnit 5.
-. JUnit Vintage provides a TestEngine for running JUnit 3 and JUnit 4 based tests on the platform.
4. 지원 버전
-. Java 8 이상
5. 사용 방법
-. JUnit 라이브러리 추가
-. JDK 1.4부터 지원하는 단정문 assert(예약어)를 활용 : 단정문은 코드 실행시, 확신한 값을 확인할 때 사용된다.
-. 어노테이션 활용 :
@Test - 테스트 메소드 지정
@BeforeAll - 모든 테스트 진행 전 실행 @BeforeEach - 각 테스트 실행 전 실행
@AfterAll - 모든 테스트 진행 후 실행 @AfterEach - 각 테스트 실행 후 실행
참고
1. Junit User Guide
https://junit.org/junit5/docs/current/user-guide/
JUnit 5 User Guide
Although the JUnit Jupiter programming model and extension model will not support JUnit 4 features such as Rules and Runners natively, it is not expected that source code maintainers will need to update all of their existing tests, test extensions, and cus
junit.org
2. 넥스트리
https://www.nextree.co.kr/p11104/
새내기 개발자의 JUnit 여행기
이번 글에서는 JUnit 단위 테스트 Framework에 대해 알아봅니다. JUnit은 Java의 단위 테스트에서 빼놓고 이야기하기 어려울 정도로 절대적인 위치를 차지하고 있습니다. 그래서 높은 수준은 아니어도
www.nextree.co.kr
'Programming > Java' 카테고리의 다른 글
[Java][Spring]BeanUtils.copyProperties() 정리 및 주의점 (0) | 2022.08.10 |
---|---|
[eclipse][spring]개발 작업에 영향을 끼치는 옵션 (0) | 2022.05.26 |
[JAVA][JUnit]자주 사용하는 Annotation (0) | 2022.03.04 |
[JAVA][TDD][CleanCode]자바 플레이그라운드 with TDD, 클린코드 시작 (0) | 2022.03.02 |