SpringMVC UnitTest
SpringMVC UnitTest 환경 구성
build.gradle
dependencies {
...
testImplementation 'org.springframework:spring-test:5.3.8'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}
TestClass
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration(classes = {APIConfiguration.class})
class ApiTestControllerTest {
...
}
tip
Junit4 에서는 @ExtendWith(SpringExtension.class) 대신에 @RunWith(SpringJUnit4ClassRunner.class) 를 사용한다.
댓글남기기