Kevin de Boer
01/30/2023, 1:48 PM@Test
@PactTestFor(providerName = "provider1", port = "1234")
public void example(MockServer provider1mock) {
...
}
However, when I do this in a multiprovider test:
@Test
@PactTestFor(pactMethods = {"createProvider1Pact", "createProvider2Pact"}, port = "1234")
public void example(@ForProvider("provider1") MockServer provider1mock, @ForProvider("provider2") MockServer provider2mock) {
...
}
I get an “address already in used” exception. Which is logical since I instantiate 2 instances of mockserver, and only provide 1 port. It tries to launch both on the same port.
However I have found no way of specifying which mockserver should use which port. Is there a way to do this?
I could not find anything in the documentation or source code, though I am unfamiliar with kotlin, I may have missed something. I tried making a subclass of MockServer and set the port myself, but then I ran into injection/instantiation issues with my new class.
Alternatively, i have also not found a way to let the application use whatever random port is chosen for the mock.Grace Sandford
01/30/2023, 4:13 PMKevin de Boer
01/31/2023, 8:31 AMGrace Sandford
01/31/2023, 9:39 AM-l 4000 and -u 4000
will set it to one port. So would have to spin up the jvm 2 times with different ports in order to force it to only give you a pact provider server running on an explicit port.Kevin de Boer
01/31/2023, 9:44 AMGrace Sandford
01/31/2023, 10:34 AM