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

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

我有一个包含两个模块的 Maven 项目,一个用于 生产者,另一个用于 消费者

Project
-- Producer module
-- Consumer module

消费者包含对生产者存根的依赖,即

<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"
)

在构建期间,consumer 的集成测试正确执行,但如果我尝试 运行 通过 IDE 在本地使用 JUnit 进行测试( IntelliJ),未找到存根且测试失败。

这是关于项目结构的问题吗?如果是这样,有没有什么我可以更改以在不更改代码的情况下使用它 运行?

Classpath 将无法从 ide 开始工作,例如Intellij 不会将存根 jar 添加到类路径中。这是 ide 的一个已知问题。