회사 안나가는 주말은 조금 여유있네요 ㅎㅎ
최근 공부하면서 막혔던 부분인데
인텔리제이에서
junit5로 설정하면서 junit4를 같이 이용하려고 gradle쪽에서 설정을 바꿨습니다.
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'junit:junit:4.13.1'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
//testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
testCompileOnly 'junit:junit:4.12'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.1.0'
}
위에 보시면 기전에는
testImplementation 'org.springframework.boot:spring-boot-starter-test'
설정했는데
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
testCompileOnly 'junit:junit:4.12'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.1.0'
로 설정하여 junit4도 사용할수있게 했습니다.
이유는 @RunWith를 사용하려고 junit4를 다시 가져왓습니다.
@RunWith(SpringRunner.class)
junit5에서는 @ExtendWith를 가져와서 사용해야하는데 이유는 모르겠지만
@ExtendWith
아래 import를 추가하면 springExtension이 없다고 나옵니다. gradle 쪽에서 추가해도 뭔가 진행되지않아서 junit4를 그대로 가져와서 쓰기로 생각했습니다.
import org.springframework.test.context.junit.jupiter.SpringExtension;
암튼 아직 혼자 독학하면서 설정 부분에서 중간중간 막히는게 시간을 잡아먹네요 코딩이야 뭐 금방하니까요 ㅎㅎ
다음에는 어노테이션에 대해서 좀 정리 해볼까합니다. ㅎㅎ 스프링에서 상당히 많이쓰이게도 하고 어떻게 구동되는지도 정리해두면 좋을것 같네요 ㅎㅎ
'웹 > Spring' 카테고리의 다른 글
@Before 실행 안될때 (0) | 2022.07.12 |
---|---|
spring 어노테이션01 (0) | 2022.07.09 |
Rest Api 란? (0) | 2022.07.01 |
assertThat의 경우 junit5에서 바로 지정되지 않는 이유가 발생! (0) | 2022.06.30 |
<Spring>Entity (0) | 2020.12.14 |