标题翻译
Spring Cloud Contract tests work with Maven but not when run with JUnit
问题
我有一个包含两个模块的Maven项目,一个用于生产者,另一个用于消费者。
项目
-- 生产者模块
-- 消费者模块
消费者模块包含对生产者存根的依赖,即:
<dependency>
<groupId>com.example</groupId>
<artifactId>producer-application</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>stubs</classifier>
<scope>test</scope>
</dependency>
集成测试配置为,StubRunner
使用类路径扫描,即:
@AutoConfigureStubRunner(
stubsMode = StubRunnerProperties.StubsMode.CLASSPATH,
ids = "com.example:producer-application:+:8090"
)
在构建过程中,消费者模块的集成测试可以正确执行,但是如果我尝试通过IDE(IntelliJ)本地运行JUnit测试,存根将无法找到,导致测试失败。
这是否是项目结构的问题?如果是,我是否可以在不更改代码的情况下使其运行?
英文翻译
I have a Maven project with two modules, one for the producer and another for consumer.
Project
-- Producer module
-- Consumer module
The consumer contains a dependency to the producer stubs, i.e.
<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, i.e.
@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.
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?
答案1
得分: 0
Classpath在IDE中不起作用,因为例如Intellij不会将存根(stubs)JAR添加到类路径中。这是IDE中已知的问题。
英文翻译
Classpath will not work from ide cause e.g. Intellij does not add the stubs jar to the classpath. It's a known issue with the ides.
专注分享java语言的经验与见解,让所有开发者获益!
评论