pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Make gradles hasPactsFromPactBroker compatible with verifying a message provider #260

Closed BenSayers closed 8 years ago

BenSayers commented 8 years ago

When I try to use the following gradle configuration:

pact {
    serviceProviders {
        "customer-details-provider" {
            verificationType = "ANNOTATED_METHOD"
            packagesToScan = ["provider.*"]
            hasPactsFromPactBroker('https://pact-broker/')
        }
    }
}

I get the following error:

Verifying a pact between customer-details-consumer and customer-details-provider
  [from URL https://pact-broker/pacts/provider/customer-details-provider/consumer/customer-details-consumer/version/0.1.0]
  Given a new customer is created
         WARNING: State Change ignored as there is no stateChange URL
  a created event for the new customer
      Request Failed - No such property: request for class: au.com.dius.pact.model.v3.messaging.Message

Failures:

0) Verifying a pact between customer-details-consumer and customer-details-provider - a created event for the new customer Given a new customer is created
      No such property: request for class: au.com.dius.pact.model.v3.messaging.Message

:pactVerify_customer-details-provider FAILED

FAILURE: Build failed with an exception.

If I configure the task to point directly to the pact file it works as expected

pact {
    serviceProviders {
        "customer-details-provider" {
            verificationType = "ANNOTATED_METHOD"
            packagesToScan = ["provider.*"]
            hasPactWith("customer-details-consumer") {
                pactFile = url("https://pact-broker/pacts/provider/customer-details-provider/consumer/customer-details-consumer/latest")
            }
        }
    }
}
BUILD SUCCESSFUL

Please add pact broker support when running message providers so providers do not need to explicitly list the consumers in their build configurations.

uglyog commented 8 years ago

Yeah, it should not make an assumption about the format of the pact from the broker.

uglyog commented 8 years ago

Could you let me know what version of the gradle plugin you are using. I'm getting a failure, but a different one to what you are getting.

uglyog commented 8 years ago

Ok, managed to replicate the error.

uglyog commented 8 years ago

I've fixed this, commit is 19a4b8d339e1ff16d4f6768be1d4d52edb9d6dc8

uglyog commented 8 years ago

Released fix with versions 3.2.8/2.4.10