2016-11-16 36 views
3

我想要test application slices,但有一個我想排除的軟件包,因爲它根本與這些測試無關。如何使用@WebMvcTest從上下文中排除軟件包

我想排除的包是這樣的:從這個包

@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

我認爲你缺少*標誌的圖案屬性,像這樣:

@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

它不帶*或無法正常工作。你試過了嗎?我會編輯我的問題 –

相關問題