Search code examples
microservicespactpact-jvm

Pact verify not working - Annotated method not found during message provider test


I have a project where we are using message provider since it involves Apache kafka based messaging.

Consumer side maven goals are working fine from local as well as from Jenkins.

Provider side pact-verify is failing in Jenkins saying "No Annotated method found for interaction".

My POM.xml config as below:

<plugin>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-maven_2.11</artifactId>
<version>3.5.2</version>
<configuration>
    <!-- pactBrokerUrl,user name,password and project version required only 
                    for consumer -->
    <pactBrokerUrl>localhost</pactBrokerUrl>
    <projectVersion>0.0.1</projectVersion>
    <!-- service provider required only for producer -->
    <serviceProviders>
        <!-- <serviceProvider><name>provider</name><verificationType>ANNOTATED_METHOD</verificationType><consumers><consumer><name>consumer</name><pactUrl>pacturl</pactUrl></consumer></consumers></serviceProvider> -->
        <serviceProvider>
            <name>provider</name>
            <verificationType>ANNOTATED_METHOD</verificationType>
            <consumers>
                <consumer>
                    <name>consumer</name>
                    <pactUrl>pacturl</pactUrl>
                </consumer>
            </consumers>
        </serviceProvider>
    </serviceProviders>
    <classpathElements>
        <classpathElement>
          src/test/java
      </classpathElement>
    </classpathElements>
    <configuration>
        <pact.showStacktrace>true</pact.showStacktrace>
    </configuration>
</configuration>
</plugin>

Solution

  • Resolved this issue. This is when we compile the project by skipping the test classes by using -Dskiptests. So right after this when we run the pact:verify the test classpaths are not included in the search.

    Fixed it by compiling the test classes by using mvn test-compile compile and then running the pact:verify. Now the classes are getting picked up every single time.