I only want to run a test if a specific property is set in the application.yml
(it's really injected via environment variable into the yml). How would I do this?
YAML (src/test/resources/config/application.yml):
tests:
ignore: ${SOME_ENV_VAR}
Test Class:
@RunWith( SpringJUnit4ClassRunner.class )
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
)
@DirtiesContext
/*** DOES THIS CAUSE IT TO IGNORE THE YAML? ***/
@TestPropertySource(
properties = {
"someprop=TESTNS"
}
)
@ActiveProfiles( "test-something" )
/*** PSEUDO CODE ***/
@IgnoreOnProperty( "tests.ignore=TestClass" )
public class TestClass
{
@Autowired
private Service service;
@SpringBootApplication(
scanBasePackageClasses = { SomeClass.class }
)
public static class Config
{
}
@Before
public void setup() throws Exception
{
//...elided...
}
@Test
public void testSomething() throws Exception
{
//...elided...
}
}