简体   繁体   English

Spring Cloud Contract 测试适用于 Maven,但不适用于 JUnit

[英]Spring Cloud Contract tests work with Maven but not when run with JUnit

I have a Maven project with two modules, one for the producer and another for consumer .我有一个包含两个模块的 Maven 项目,一个用于生产者,另一个用于消费者

Project
-- Producer module
-- Consumer module

The consumer contains a dependency to the producer stubs, ie消费者包含对生产者存根的依赖,即

<dependency>
    <groupId>com.example</groupId>
    <artifactId>producer-application</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <classifier>stubs</classifier>
    <scope>test</scope>
</dependency>

and the integration tests are configured so StubRunner uses classpath scanning, ie并且配置了集成测试,以便StubRunner使用类路径扫描,即

@AutoConfigureStubRunner(
        stubsMode = StubRunnerProperties.StubsMode.CLASSPATH,
        ids = "com.example:producer-application:+:8090"
)

During build, the integration tests for the consumer are executed correctly but if I try to run the tests locally with JUnit through the IDE (IntelliJ), the stubs are not found and tests fail.在构建期间,消费者的集成测试被正确执行,但如果我尝试通过 IDE (IntelliJ) 使用 JUnit 在本地运行测试,则找不到存根并且测试失败。

Is this an issue on how the project is structured?这是关于项目结构的问题吗? If so, is there something I can change to have it run without changing the code?如果是这样,是否可以更改某些内容以使其在不更改代码的情况下运行?

Classpath will not work from ide cause eg Intellij does not add the stubs jar to the classpath.类路径在 ide 中不起作用,例如 Intellij 不会将存根 jar 添加到类路径中。 It's a known issue with the ides.这是 ide 的一个已知问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用spring-cloud-contract-oa3和spring cloud contract gradle插件时无法生成合约测试 - Unable to generate contract tests when using spring-cloud-contract-oa3 and spring cloud contract gradle plugin mvn clean install对于我的春季云合同消费者测试是成功的,但是当我手动运行测试时,它们失败了吗? - mvn clean install is SUCCESS for my spring-cloud-contract consumer tests, but when I run the tests manually they are FAILING? Maven 测试不使用 Spring Boot 2.2 和 JUnit 5 运行 Cucumber 场景 - Maven Tests Does Not Run Cucumber Scenarios with Spring Boot 2.2 and JUnit 5 使用maven时Spring Cloud Contract编译问题 - Spring Cloud Contract compilation problems when using maven 使用 Maven 运行 JUnit 测试时,Spring MockMvc WebApplicationContext 为 null - Spring MockMvc WebApplicationContext is null when running JUnit Tests with Maven 如何在不构建项目中的所有单元和合同测试的情况下生成和运行单个合同测试? Java Spring Cloud 合约验证器 - How to generate and run a single contract test without building all the unit and contract tests in the project? Java Spring Cloud Contract Verifier 生成的测试在Spring Cloud Contract中失败 - Generated tests fail in Spring Cloud Contract Spring Cloud Contract 在合约文件中使用 bodyFromFile 生成弱测试 - Spring Cloud Contract generates weak tests using bodyFromFile in contract file Maven无法在mvn -test上运行Junit测试 - Maven failing to run Junit Tests on mvn -test 如何在 Maven 中按类别运行 JUnit 测试? - How to run JUnit tests by category in Maven?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM