James Fraser
03/28/2023, 8:09 AMpactVerify
Gradle command to run for my message provider - it doesn’t seem to be able to find the methods I’ve annotated even though it should be on the test classpath
I’ve commented out the packagesToScan
section in my Gradle and it still can’t find it, it just gives me an error:
No annotated methods were found for interaction 'message.interaction.name'. You need to provide a method annotated with @PactVerifyProvider("message.interaction.name") on the classpath that returns the message contents.
I have a method annotated correctly in my test directory (the test runs and passes if I run it using JUnit):
@PactVerifyProvider("message.interaction.name")
public String verifyInteraction() {
...
}
My build.gradle currently looks like this:
pact {
broker {
pactBrokerUrl = "$System.env.PACT_BROKER_BASE_URL"
pactBrokerToken = "$System.env.PACT_BROKER_TOKEN"
}
serviceProviders {
providerName {
verificationType = 'ANNOTATED_METHOD'
// packagesToScan = ['*']
hasPactsFromPactBroker("$System.env.PACT_BROKER_BASE_URL", authentication: ['Bearer', "$System.env.PACT_BROKER_TOKEN"])
}
}
}
If you’ve any suggestions on what I could try in order to sort this I’d really appreciate it - thanks 😄Timothy Jones
03/28/2023, 8:30 AMpackagesToScan
to tell it where your test isTimothy Jones
03/28/2023, 8:31 AMJames Fraser
03/28/2023, 8:31 AMJames Fraser
03/28/2023, 8:32 AM@Provider("providerName")
@PactBroker(url = "url",
authentication = @PactBrokerAuth(token = "token"))
public class ProviderMessageTest {
...
Timothy Jones
03/28/2023, 8:35 AMJames Fraser
03/28/2023, 8:40 AMJames Fraser
03/28/2023, 8:41 AM4.3.19
, 4.4+ seems to give me an error due to my Gradle version (which is currently locked for the project I’m working on)James Fraser
03/28/2023, 8:49 AM4.5.3
locally and still get the same erroruglyog
ProviderMessageTest
is in? That is what you should set packagesToScan
to. Where does this test class sit, is it in another module?
What JDK are you using?James Fraser
03/29/2023, 8:37 AMprovider_service
and provider_service_api
, the service is the provider), each with their own build.gradle
, the Gradle snippet I shared is from the repo’s root build.gradle
Its package is com.company.providername.pact
, which is what I had originally set it to
The test file is in provider_service/src/test/unit/java/com/company/providername/pact/
My JDK seems to be set to 17uglyog
provider_service
to the build classpath of the root Gradle project. When the Gradle plugin runs, it uses the build classpath to load classes, not the project compile or test classpaths.uglyog
James Fraser
03/30/2023, 8:36 AM