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

Is RestPactRunner compatible with V4Pact? #1692

Closed metteo closed 7 months ago

metteo commented 1 year ago

Hi

Asking here instead of SO because it seems to be a bug / omission.

I have a situation where consumer is publishing a V4Pact in pactflow. Provider test is fetching it correctly (under debugger) but then PactRestRunner filters it out because it's not an instance of RequestResponsePact...

I'm wondering if that filtering expression should include || pact.isRequestReponsePact() and some conversion logic (pact.asRequestResponsePact()) down the line.

I'm using pact-jvm 4.3.x which is marked as unsupported, but PactRestRunner was not touched since 2020..

metteo commented 1 year ago

I have overridden filtering method and included above condition / conversion logic. I can confirm it works for executing the tests. Not sure about publishing the verifications, will report tomorrow.

metteo commented 1 year ago

So I identified another problem. During conversion to RequestResponsePact source field is initialized with a default UnknownPactSource instead of the one from V4Pact which is BrokerUrlSource. This prevents publishing of verifications.

rholshausen commented 1 year ago

Support was only added for JUnit 5. None of the JUnit 4 code has been touched.

metteo commented 1 year ago

@rholshausen thanks for the reply. It confirmed my suspicions.

As I mentioned above I was able to make minor modifications on top of SpringRestPactRunner to enable support of V4 pacts. I tested the whole provider part so: fetching from broker, running the tests and publishing the verifications back (but only for RequestResponsePact).

I'm not sure what your plans are regarding junit4 and V4Pact. Is the combination unsupported for the provider side? Are there plans to implement it but at a later stage?

I'm asking because I have a project with some hard to untangle dependencies (spring, camel, junit4 based integration test) where switching to junit5 is planned but will take time.