Tarek
Tarek

Reputation: 3160

How to skip the test generation maven goal with Spring Cloud Contract Verifier?

I want to test a service Consumer that uses FeignClient to call another service, Producer, that I have. In order to stub the service called, I'm using spring-cloud-contract-verifier for the producer and spring-cloud-contract-stub-runner on the consumer.

My problem is that I already have written integration tests for the producer, so I'd just like to generate the stubs and skip the tests generation. Using the spring-cloud-contract-maven-plugin, I've tried to set up only the goals I need, but it's still trying to run the tests anyway. I suspect I'm not setting it up correctly...

<plugin>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-contract-maven-plugin</artifactId>
    <version>${spring-cloud-contract.version}</version>
    <extensions>true</extensions>
    <executions>
        <execution>
            <goals>
                <goal>convert</goal>
                <goal>generateStubs</goal>
            </goals>
            <configuration>
                <basePackageForTests>com.example</basePackageForTests>
            </configuration>
        </execution>
    </executions>
</plugin>

when I run mvn clean install, it's still expecting a TestBase. How can I skip this goal?

Upvotes: 1

Views: 2828

Answers (3)

Avinash Kadam
Avinash Kadam

Reputation: 616

Set mavenTestSkip property to true to skip contract test generation. Refer

<plugin>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-contract-maven-plugin</artifactId>
    <version>4.0.5</version>
    <extensions>true</extensions>
    <configuration>
        <mavenTestSkip>true</mavenTestSkip>
    </configuration>
</plugin>

Upvotes: 0

KarthikaSrinivasan
KarthikaSrinivasan

Reputation: 599

If you want to skip contract tests use <skipTests>true</skipTests> in your cloud contract plugin. This will create stubs and skipTests will skip running contracts

Upvotes: 0

Marcin Grzejszczak
Marcin Grzejszczak

Reputation: 11159

If you check the documentation (https://cloud.spring.io/spring-cloud-static/spring-cloud-contract/1.2.4.RELEASE/spring-cloud-contract-maven-plugin/generateTests-mojo.html) you'll see that you can do a number of things. -DskipTests, -Dspring.cloud.contract.verifier.skip=true. Always read the documentation.

Upvotes: 2

Related Questions