목차
1. gradle 설정
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo.spring30x:4.9.3'
gradle에 위의 dependency 추가
spring boot 3.0.4 버전을 사용 중이므로 30x 사용
2. application-test.properties 설정
de.flapdoodle.mongodb.embedded.version=4.4.18
spring.data.mongodb.uri=mongodb://localhost:27017/testDB
application-test.properties에 위와 같이 설정
3. Test 파일 설정
@DataMongoTest
@ExtendWith(SpringExtension.class)
@TestPropertySource(locations = "classpath:application-test.properties")
참고 사이트
https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo.spring
'Spring' 카테고리의 다른 글
| [Spring test] Repository Unit Test ManyToOne (0) | 2023.09.26 |
|---|---|
| [Spring] QueryDSL 사용하기 (0) | 2023.09.25 |