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

Results are not published to pact broker when @PactFilter annotation is present #936

Open oswaldquek opened 5 years ago

oswaldquek commented 5 years ago

It seems that with the following configuration on a pact provider test:

@RunWith(PactRunner.class)
@Provider("provider")
@PactBroker(scheme = "https", host = "pact-broker-test.cloudapps.digital", tags = {"${PACT_CONSUMER_TAG}"},
        authentication = @PactBrokerAuth(username = "${PACT_BROKER_USERNAME}", password = "${PACT_BROKER_PASSWORD}"),
        consumers = {"consumer"})
@PactFilter({"some state",
        "another state"
})

results are not published to the pact broker. if I remove the au.com.dius.pact.provider.junit.loader.PactFilter annotation from my test I see

{"level":"WARN","logger":"au.com.dius.pact.provider.DefaultTestResultAccumulator","thread":"main","message":"Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')","service-name":"ledger-service","@timestamp":"2019-09-04T10:08:02.709+0000"}

I think this somewhat relates to https://github.com/DiUS/pact-jvm/issues/522. I'm not positive a verification result should be published to the pact broker if only a subset of interactions (filtered by the @PactFilter) are played. I agree this will add a lot of complexity and perhaps this PactFilter feature should be re-thought.

uglyog commented 5 years ago

The fix to #522 results in the verification result being published if all the interactions have a result. If the result of applying your filter means that there is at least one interaction without a result, it will not publish anything.

You need to make sure there are tests that exercise all the combinations. I.e., if there are interactions that don't have provider states "some state" and "another state" there needs to be a test for those.