简体   繁体   中英

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 .

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

@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?

Classpath will not work from ide cause eg Intellij does not add the stubs jar to the classpath. It's a known issue with the ides.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM