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.09k stars 480 forks source link

Provide Pact Broker tags 'lazily' #651

Open Thorn1089 opened 6 years ago

Thorn1089 commented 6 years ago

The @PactBroker annotation allows me to either hard-code tags, or provide them using a system property. The system property lets me specify different tags at runtime, which is great for doing things like testing both develop and master branches on my CI server.

However, it'd be even better if I could specify tags dynamically at runtime. As a specific example, I'd like to write a JUnit test that would determine the current Git branch at runtime and add that branch name to the tags to be tested against (in addition to latest stable develop and master tags). I can manually specify these things in places like Eclipse run configurations or on the command line but that gets tedious.

I'm not sure how this would work in practice - perhaps something similar to the HttpTarget proposal allowing a callback to be provided to determine a dynamic port at runtime, where there could be a PactBroker rule instead of an annotation that accepts either static values, property keys, or callbacks?

uglyog commented 6 years ago

This is a good idea. I generally achieve this with the build configured to set the tags up (Gradle build configures the system properties on the test task), but maybe something like this would be easier to configure.