我有一个问题:什么是正确的配置,以仅加载我要在该集成测试中测试的Enpoint类,而不加载整个应用程序上下文(不是所有Enpoint类)?现在我有:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {WebServiceConfigTest.class}, properties = {"application.address=http://hostname:port/context"})
public class MyEndpointTest {
@Autowired
private ApplicationContext applicationContext;
private MockWebServiceClient mockClient;
@Before
public void init() {
mockClient = MockWebServiceClient.createClient(applicationContext);
MockitoAnnotations.initMocks(this);
}
@Test
public void test1(){}
....
}
在WebServiceConfigTest中为:
@ComponentScan("mypackages.soap")
@ContextConfiguration(classes = SoapApplication.class)
@MockBean(classes = {MyService.class})
public class WebServiceConfigTest {
}
SoapApplication是:
@ComponentScan({"mypackages"})
@SpringBootApplication
public class SoapApplication extends SpringBootServletInitializer implements WebApplicationInitializer {
public static void main(String[] args) {
SpringApplication.run(SoapApplication.class, args);
}
}
原因是在Soap模块中,我有一个Service模块的依赖项,而Service模块也有其他依赖项,依此类推。如果我加载整个ApplicaitonContext,则:
如果第二步,将使Soap模块意识到它不应该知道的事情。如果我先这样做,则必须模拟并在config测试文件中维护使用的服务的完整列表,该列表可能很长。
这里有什么建议吗?
我有一个疑问:什么是正确的配置,它仅加载要在该集成测试中测试的Enpoint类,而不是整个应用程序上下文(不是所有Enpoint类)? ...
什么是正确的配置,它仅加载我要在该集成测试中测试的Endpoint类,而不加载整个Application上下文,所以>