I use this in my MyService.kt
.
The useXml
is read via application.yml
and application-test.yml
@Service
class MyService (
@Value("\${something.use-xml}")
var useXml: Boolean = false
) {
if(useXml) {
// do this
} else {
// do that
}
....
}
this works as expected.
but for the testing I want to use both variation:
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class MyFunctionalTest {
@Value("\${something.use-xml}")
var useXml: Boolean = false
//....
@ParameterizedTest
@ValueSource(booleans = [true,false])
fun `do a parameterized test`(useXML : Boolean) {
useXml = useXML // this is (of course) not setting the variations for `MyService.kt`
if (useXML) {
// test this
} else {
// test that
}
}
I want a possibility where I can set the variable for the application.yml
file, so both variations are tested.
Is there any way of doing it?