반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- java 11
- springbatch error
- maybe not public or not valid?
- AWS CLI
- no sources given
- aws
- OpenFeign
- springboot
- property or field 'jobparameters' cannot be found on object of type
- el1008e
- easy
- LeetCode
- java 여러개 버전
- java
- mac os git error
- Medium
- JUnit
- 스프링부트테스트
- No tests found for given includes
- querydsl no sources given
- xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
- java version
- java 버전 변경
- parse
- error
- java 1.8 11
- yum install java
- Java 1.8
- log error
- springboottest
Archives
- Today
- Total
쩨이엠 개발 블로그
[ Spring ] SpringBoot test 순서 / 이름 정하기 (@TestMethodOrder / @DisplayName) 본문
개발/Spring
[ Spring ] SpringBoot test 순서 / 이름 정하기 (@TestMethodOrder / @DisplayName)
쩨이엠 2020. 5. 20. 12:13728x90
반응형
테스트 시 이 테스트가 어떤건지 설명이 필요할 때 그리고 순서를 정해서 돌리고 싶을 때 사용하는 어노테이션 두개가 있다
@TestMethodOrder
@DisplayName
@TestMethodOrder
필요한 dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
DataServiceTests.java
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
class DataServiceTests {
@InjectMocks
private DataService service;
@Mock
private DataMapper mapper;
.
.
.
.
}
@TestMethodOrder annotation을 class 위에 써준다
그리고 테스트 할 케이스 위에 Order 어노테이션을 붙여준다
DataServiceTests.java
@Order(1)
@Test
void test_InspectQcData(){
.
.
.
}
이러면 알파벳 순이 아닌 Order 숫자 순으로 테스트가 진행되는 것을 볼 수 있다
MethodOrderer.OrderAnnotation.class를 좀더 짧게 하고 싶다면 static import를 통해 더 짧게 만드는것이 가능하다
import static org.junit.jupiter.api.MethodOrderer.*;
테스트 결과
@DisplayName
여기서 좀더 이쁘게 하고 싶다면
Test할 함수 위에 @DisplayName 어노테이션을 추가한다
@DisplayName(“QC 통합 테스트”)
@Order(1)
@Test
void test_InspectQcData(){
.
.
.
}
테스트결과
728x90
반응형
'개발 > Spring' 카테고리의 다른 글
Maven pom to gradle (0) | 2020.07.13 |
---|---|
[ Spring ] spring init 초기화 메소드 @PostConstruct (0) | 2020.07.01 |
[ Spring ] Failed to determine a suitable driver class (0) | 2020.06.29 |
[ Spring ] Springboot test - mockito (Mapper 접근) (0) | 2020.05.19 |
[ Spring ] Spring boot Test (@RunWith, @ExtendWith) (0) | 2020.05.09 |
Comments