-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Set mock ports for multiple providers? #1675
Comments
👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-807). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps. |
I've added support for multiple @MockServerConfig annotations, so you can now do @ExtendWith(PactConsumerTestExt.class)
@MockServerConfig(providerName = "provider1", port = "1234")
@MockServerConfig(providerName = "provider2", port = "1235")
class MultiProviderWithStaticPortsTest { The provider names must match the ones used to setup the Pacts. See https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/MultiProviderWithStaticPortsTest.java#L26 |
That's awesome! Thank you! |
Closed in 67a6670 |
This question was also asked on StackOverflow by someone else but has yet to receive a response.
In my case I am not using Spring (as that previous entry on StackOverflow is) but I have the same problem: I have a single business method which calls 2 providers. Each provider is statically configured in the application configuration. Injecting a
MockServer
into the test method doesn't help because the framework itself creates the client implementation (see https://quarkus.io/guides/rest-client-reactive#create-the-interface). The URL for the client is configured at the application level, so the ports of both mock servers need to be known statically before the test class is even created.Separating into 2 separate tests for each provider is impossible. What we need is either
@PactTestFor
annotation the ability to specify a port per provider.In my particular case for this exact problem, a single mock server would work because both providers have different context paths that get called. But generically, that may not work for all use cases.
The text was updated successfully, but these errors were encountered: