question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AmpqTestTarget not finding @PactVerifyProvider, JUnit5, Java 11

See original GitHub issue

Hi, i am having the same issue as mentioned here https://github.com/DiUS/pact-jvm/issues/763.

Using:

<dependency>
            <groupId>au.com.dius</groupId>
            <artifactId>pact-jvm-provider-junit5_2.12</artifactId>
            <version>3.6.14</version>
 </dependency>

And :

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
    <useSystemClassLoader>false</useSystemClassLoader>
</configuration>

My test looks like this:

@Provider("user-service")
@PactBroker
public class UserPactTest {

    @TestTemplate
    @ExtendWith({PactVerificationInvocationContextProvider.class})
    public void pactVerificationTestTemplate(PactVerificationContext context) {
        context.verifyInteraction();
    }

    @BeforeEach
    public void setUp(PactVerificationContext context) {
        context.setTarget(new AmpqTestTarget(Collections.singletonList("my.package.pact")));
    }

    @PactVerifyProvider("user created message")
    public String verifyUserCreatedMessage() throws JsonProcessingException {
        // some code that just returns string from object with object mapper
    }
}

I’ve tried multiple version of surefire plugin, tried using empty constructor for AmpqTestTarget but everything ends with: user created message No annotated methods were found for interaction 'user created message'. You need to provide a method annotated with @PactVerifyProvider("user created message") that returns the message contents.

The test doesnt work from both IDE(Intellij) and maven. I just cant get it to work so any help would be appreciated.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mkluzacekcommented, Mar 23, 2020

Thank you very much for your help. I was finally able to fix it. Problem was the dependency. I was using:

<dependency>
            <groupId>au.com.dius</groupId>
            <artifactId>pact-jvm-provider-junit5_2.12</artifactId>
            <version>3.6.14</version>
</dependency>

Instead of :

<dependency>
            <groupId>au.com.dius</groupId>
            <artifactId>pact-jvm-provider-junit5</artifactId>
            <version>4.0.7</version>
            <scope>test</scope>
</dependency>

No idea where i found the first one. Thanks again.

0reactions
jespernordSPLcommented, Mar 4, 2021

I upgraded a service to Java 11 + Junit 5, got the same problem. In my case it was because of a trailing star in the packages list:

@TestTarget public final Target target = new AmqpTarget(Collections.singletonList("com.example.my.package.*"));

which had to be replaced with (no star at end of package):

@BeforeEach
void before(PactVerificationContext context) {
    context.setTarget(new MessageTestTarget(List.of("com.example.my.package")));
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

AmpqTestTarget not finding @PactVerifyProvider, JUnit5 ...
Hi, i am having the same issue as mentioned here #763. Using: au.com.dius pact-jvm-provider-junit5_2.12 3.6.14 And : org.apache.maven.plug.
Read more >
AmpqTestTarget - javadoc.io
This target will look for methods with a @PactVerifyProvider annotation where the value is the description of the interaction.
Read more >
Having trouble in verifying the PACT from provider side using ...
I have to do PACT verification in java + ...
Read more >
Pact Junit 5 Extension | Pact Docs
For writing Pact verification tests with JUnit 5, there is an JUnit 5 ... The Java packages to scan to find classes with...
Read more >
au.com.dius.pact.provider : junit5 : 4.1.1 - Maven Central
This will generate a test for each interaction found for the pact files for ... **NOTE: JUnit 5 tests do not use `@TargetRequestFilter`**...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found