I am new to PACT. My application is a spring boot application. Consumer has pact created in PACT broker. Now I am trying to run tests from providers end and I am using gradle plugin to run tests. I have couple of questions:
Pact published by consumer do not have any states specified. So this means I don't have to use any stateChangeUrl at provider side ?
Pact published has get method. However when I run pactVerify server starts and my pact tests are failing because I don't have any existing data. How can I inject data after.
What I am trying to achieve is: When I say pactVerify
Below is my gradle file
pact {
serviceProviders {
'user-api' {
protocol = 'http'
host = 'localhost'
port = 8080
startProviderTask = startService
terminateProviderTask = stopService
if ('pactVerify' in gradle.startParameter.taskNames) {
hasPactsFromPactBroker('http://pactbroker.com') {
< How to write some code here to say do POST before running PACT >
}
}
}
}
- Pact published by consumer do not have any states specified. So this means I don't have to use any stateChangeUrl at provider side ?
It means you have chosen not to use this mechanism to change states, and therefore yes, you don't need to use that URL. But you may wish to change your mind on that.
- Pact published has get method. However when I run pactVerify server starts and my pact tests are failing because I don't have any existing data. How can I inject data after.
Why not inject the data before you start all of the tests? If you don't have states to worry about, then you may as well just start the provider with the data pre-loaded into the database.
As noted, all of the configuration info can be found at https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-gradle.