如果在application.yml
中设置了特定属性(它实际上是通过环境变量注入到yml中),我只想运行测试。我该怎么做?
YAML(src / test / resources / config / application.yml):
tests:
ignore: ${SOME_ENV_VAR}
测试类:
@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...
}
}