我想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 ...
}
无论如何,此包中的类都包含在上下文中。如何解决?
答案 0 :(得分:0)
我认为你缺少*签署模式属性,如下所示:
@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 ...
}