I'm running unit tests and the underlying code relies on the presence of some environment variables. Not application properties, but actual system environment variables. If they're not present, the app will die.
Gradle Test Block
test {
useJUnitPlatform()
testLogging {
exceptionFormat "full"
showExceptions = true
showStackTraces = true
showStandardStreams = true
}
environment "APP_ID", "id"
environment "STATSD_HOST", "localhost"
environment "STATSD_PORT", "8125"
}
Unit Test
@SpringBootTest
@TestPropertySource(value = "classpath:application-test.properties")
public class MyCoolTest {
...
But I'm still getting an NPE on this value. This works if I force the env variable in intellij IDE explicitly, but I don't want to do it that way. Any suggestions?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…