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 478 forks source link

Groovy DSL method invocation order affects behaviour #1287

Open topr opened 3 years ago

topr commented 3 years ago

After upgrading from 3.x to 4.1.x I've noticed consumer side no longer publishes providerStates on some Pacts we have. It took quite a while to narrow the thing down. In Short:

new PactBuilder().with {
    given 'foo'
    uponReceiving 'bar'
    // ...
}

...works as expected whilst:

new PactBuilder().with {
    uponReceiving 'bar'
    given 'foo'
    // ...
}

...does not publish the state.

Is it by design?

Although it makes more sense to declare a state first and then an action, order of DSL method invocations shouldn't really matter, should it?

Thanks!

uglyog commented 3 years ago

That's not by design, it is probably a regression.

topr commented 3 years ago

Thanks for the confirmation. That was a tricky one to nail, I've learnt a lot about the Pacts mechanics while doing so though :wink: