我想test application slices,但有一个我想要排除的包,因为它与那些测试根本没有关系.
我试图以这种方式排除包:
@RunWith(SpringRunner.class)
@WebMvcTest(controllers = MyController.class,
excludeFilters = {@ComponentScan.Filter(
type = FilterType.REGEX, pattern = "com.foo.bar.*")})
public class MyControllerTest {
// ... list of test methods goes here ...
}
无论如何,此包中的类都包含在上下文中.怎么解决?
解决方法:
我认为你缺少*在pattern属性中签名,如下所示:
@RunWith(SpringRunner.class)
@WebMvcTest(controllers = MyController.class,
excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.foo.bar.*")})
public class MyControllerTest {
// ... list of test methods goes here ...
}
标签:java,spring,testing,spring-boot-2
来源: https://codeday.me/bug/20190711/1429268.html