Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to set dynamic provider names (CI/CD in Java without maven plugin) #1160

Open
spspunkt-team opened this issue Jul 6, 2020 · 2 comments

Comments

@spspunkt-team
Copy link

Hello,

We have a scenario, where a provider test (Java, Junit5, Pact Broker & Quarkus-Test as API-Provider) should be executed in CI/CD. Therefor, the provider name should be set from CI/CD:

@QuarkusTest
@Provider("my-project-name-from-CI-CD") // is there an API for setting the name at runtime?
@PactBroker(host = "${pactbroker.host}", port = "${pactbroker.port}")
public class PactDemoIT {

	@BeforeAll
	static void init() {
		System.setProperty("pact.provider.version", System.getProperty("project.version", "unkown"));
		System.setProperty("pact.verifier.publishResults", "true");
	}

	@TestTemplate
	@ExtendWith(PactVerificationInvocationContextProvider.class)
	void pactVerificationTestTemplate(PactVerificationContext context) {
		context.verifyInteraction();
	}

	@BeforeEach
	void init(PactVerificationContext context) throws Exception {
		context.setTarget(HttpTestTarget.fromUrl(new URL(RestAssured.baseURI + ":" + RestAssured.port)));
	}

	@State({ "datastage0" })
	void initState() {
	}
}
@uglyog
Copy link
Member

uglyog commented Jul 12, 2020

You can now leave the provider name out (the annotation is still required), and use the pact.provider.name system property.

You should also be setting these values from your CI/CD pipeline:

        @BeforeAll
	static void init() {
		System.setProperty("pact.provider.version", System.getProperty("project.version", "unkown"));
		System.setProperty("pact.verifier.publishResults", "true");
	}

@uglyog
Copy link
Member

uglyog commented Aug 9, 2020

4.1.7 has been released with this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants