Search code examples
spring-bootmockmvcspring-cloud-contract

Spring cloud Contract verifier baseClassMapping no longer working in 3.0.0


The below config works fine perfectly in spring-cloud-starter-contract-verifier 2.2.4.RELEASE. But with 3.0.0 it throws the error below, it is not deprecated in the docs. Does anyone know if the behavior is changed ?

  • .pom file
<plugin>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-contract-maven-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <baseClassForTests>com.mycompany.selectservice.integrationtest.</baseClassForTests>
        <baseClassMappings>
        <baseClassMapping>
            <contractPackageRegex>.*select.*</contractPackageRegex>
            <baseClassFQN>com.mycompany.selectservice.integrationtest.SelectBaseTest</baseClassFQN>
        </baseClassMapping>
        </baseClassMappings>
    </configuration>
</plugin>

SelectTest.validate_contract_0:33 » IllegalState You haven't configured a MockMvc.

My spring boot version is 2.2.4.RELEASE, So it means that spring-cloud-starter-contract-verifier 3.0.0 cannot be used with spring boot 2.2.4.release?


Solution

  • As described in our project page (https://spring.io/projects/spring-cloud) you have to use Boot 2.4 to use Spring Cloud Contract. Also, that functionality does work - most likely you're using some old imports or you're using JUnit4 (the default now is JUnit5).