-
Notifications
You must be signed in to change notification settings - Fork 3
springboot_test_configuration
choisungwook edited this page Oct 7, 2021
·
4 revisions
- sringboot ํ ์คํธ ์ค์
- build.gradle ์ค์
- ํ ์คํธ ์คํ๋งํ๋กํ์ผ(application-test.yml)ํ์ผ ์์ฑ
- ํ ์คํธ์ฝ๋์ @SpringbootTest ์ ๋ ธํ ์ด์ ์ค์ ๊ณผ ํ ์คํธ ์คํ๋งํ๋กํ์ผ ๋ก๋ ์ค์
- ์คํ๋ง ํ๋กํ์ผ์ ๋ฐํ์ ์ ๋ก๋ํ ์ ์๋๋ก bootRun์ค์
bootRun {
String activeProfile = System.properties['spring.profiles.active']
systemProperty "spring.profiles.active", activeProfile
}
- h2, springboot test๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ถ๊ฐ
runtimeOnly 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
- @SpringbootTest ์ ๋ ธํ ์ด์ ๊ณผ ์คํ๋งํ๋กํ์ผ ์ค์
@SpringBootTest(properties = "spring.config.location=classpath:application-test.yml")
class AccountServiceTest {
...
}