AmqpTarget doesn't find @PactVerifyProvider annotation
See original GitHub issueI’m running a simple message provider test:
@RunWith(PactRunner.class)
@Provider("userservice")
@PactFolder("../pact-message-consumer/target/pacts")
@SpringBootTest
public class MessageProviderTest {
@TestTarget
public final Target target = new AmqpTarget(Collections.singletonList("io.reflectoring"));
@PactVerifyProvider("a user created message")
public String verifyUserCreatedMessage() {
return "{\"testParam1\": \"value1\",\"testParam2\": \"value2\"}";
}
}
Executing this test results in
Failures:
0) a user created message
No annotated methods were found for interaction 'a user created message'. You need to provide a method annotated with @PactVerifyProvider("a user created message") that returns the message contents.
The cause for this is that the Reflections
call in ProviderVerifier#verifyResponseByInvokingProviderMethods
doesn’t find the @PactVerifyProvider
annotation on my test method. There must be something wrong with the setup of the Reflections
instance (class loader?).
When I’m using the following code snippet from a test, the annotation is found:
Reflections r = new Reflections(ClasspathHelper.forPackage("io.reflectoring"), new MethodAnnotationsScanner());
Set<Method> methods = r.getMethodsAnnotatedWith(PactVerifyProvider.class);
Issue Analytics
- State:
- Created 5 years ago
- Comments:20 (13 by maintainers)
Top Results From Across the Web
AmqpTarget doesn't find @PactVerifyProvider annotation #763
I'm running a simple message provider test: @RunWith(PactRunner.class) @Provider("userservice") @PactFolder(".
Read more >Pact verify not working - Annotated method not found during ...
When doing producer side testing you need to provide the JSON contract. In those contracts you have the name of the producer.
Read more >au.com.dius.pact.provider.junit.target.AmqpTarget Maven ...
Rule** JUnit annotations, that will be run before/after each test of an ... name of tested provider @PactFolder("pacts") // Point where to find...
Read more >Testing a Spring Message Producer and Consumer against a ...
This annotation is part of the standard Java Bean Validation annotations we'll ... You can find the code for the consumer in my...
Read more >pact-jvm
Pact will automatically search for test method which is annotated with @PactVerifyProvider("") and will match the message returned by test method & the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@eranberg I was experiencing the same issue but with
3.6.4
. I found that after upgradingmaven-surefire-plugin
, everything started to work:Intermediate versions may work, however I didn’t look into it.
Had this issue as well. My issue is that I am using Java 11. Upgraded to
pact-jvm-consumer-junit
version4.0.0-beta.2
and I have provider verification working again.