udeConfig1 {
}
再来看看结果(TestConfigExclude_1_Test):
@SpringBootTest(classes = ExcludeConfig1.class)
public class TestConfigExclude_1_Test extends AbstractTestNGSpringContextTests {
@Autowired(required = false)
private TestConfig testConfig;
@Test
public void test() throws Exception {
assertNull(testConfig);
}
}
还可以用@SpringBootApplication来排除TestConfig(ExcludeConfig2):
@SpringBootApplication
public interface ExcludeConfig2 {
}
看看结果(TestConfigExclude_2_Test):
@SpringBootTest(classes = ExcludeConfig2.class)
public class TestConfigExclude_2_Test extends AbstractTestNGSpringContextTests {
@Autowired(required = false)
private TestConfig testConfig;
@Test
public void testPlusCount() throws Exception {
assertNull(testConfig);
}
}
参考文档