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

running pact provider tests without PactRunner annotation #880

Open pawel-kaminski-krk opened 5 years ago

pawel-kaminski-krk commented 5 years ago

hi, I am quite fresh to the library and I must admit that being forced to use @RunWith(PactRunner.class) in order to use pact is a bit ugly and too strong! And yeah! this is just my opinion but I hope some of you agree. :)

I was running through the code and I see that you provide a lot of runners including SpringPactRunner which shows the problem.

I would like to see something like PactRunner.runWith(this) which can initialize pact and generate tests for given pact definition based on given annotation

@Provider("X")
@PactFolder("somewhere")
@VerificationReports(value={"console", "markdown"}, reportDir="build/pacts")

Now I have lots of conflicts with my existing setup and I have to move pact to separate directory and hack my service configuration.

I think providing such functionality would make pact integration with any code much cleaner. and existing runners could just call same code adding its logic on top of that.

If I missed it, please point me to some examples or source code or lets talk how to improve pact for jvm. thanks.

pawel-kaminski-krk commented 5 years ago

and giving it more though I think that probably such integration should work more as parametrised test generator rather than whole runner

uglyog commented 5 years ago

JUnit 5 supports this using the test extensions, so having the single runner is no longer necessary. I am hesitant to do any work with JUnit 4 as JUnit 5 is the platform going forward.