[英]@IntegrationTest in spring boot makes concordion tests fail when run in combination with 'normal' unit tests
我正在使用Concordion进行我的Spring Boot REST API的端到端测试。 我发现我可以使用@IntegrationTest批注让手风琴测试启动我的spring应用程序。 如果我手动运行1个concorion测试或所有conordion测试,这将起作用。但是,如果我包括常规单元测试(不带@IntegrationTest),则该conordion测试将失败,并出现org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8080/myrestservice":Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect.
org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8080/myrestservice":Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect.
如果我使用@IntegrationTest批注注释我的常规单元测试,则所有方法都可以使用。 但是我想知道是否有人知道更好的方法?
编辑:我的手风琴测试和单元测试都具有以下其他注释:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = Application.class,
loader = SpringApplicationContextLoader.class)
@WebAppConfiguration
我猜您在所有测试中共享了一个缓存的ApplicationContext
。 您可以通过更改配置源(例如,添加一个空的TestConfiguration.class
)或使用配置文件(例如,“ @ ActiveProfiles(“ integration”))来更改缓存键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.