Using Random port with jvm-provider-spring and SpringRestPactRunner
See original GitHub issueThe @TestTarget
annotation is called before the Spring Boot application starts. This makes it impossible for me to get a random port and this makes us need to find separate port for each and every microservice.
Is there any known solution for this?
@RunWith(SpringRestPactRunner.class)
@Provider("someservice")
@IgnoreNoPactsToVerify
@PactBroker(<something>)
// We need to have random port so that we dont have to manually find available ports for all services
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PactVerificationTest {
@LocalServerPort
int serverPort;
// When this annotation is invoked, the serverPort variable has not yet been assigned.
@TestTarget
public final Target target = new HttpTarget(serverPort);
(...)
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Using Random port with jvm-provider-spring and ...
This makes it impossible for me to get a random port and this makes us need to find separate port for each and...
Read more >Pact Spring/JUnit runner
If you use a random port in a springboot test (by setting SpringBootTest.WebEnvironment.RANDOM_PORT ), you need to set it to the TestTarget ....
Read more >Pact testing using random port with jUnit5 and SpringBoot
I can't get the pact provider tests to run on any other port than 8080 when using jUnit5. I have the following code:...
Read more >Get the Running Port in Spring Boot
Here, we need to activate the “randomport” Spring profile to load the corresponding properties file.
Read more >Upgrading to use JUnit 5 for Spring Pact tests
Previously SpringBootHttpTarget set up the target from the random port automatically but now we need to set the PactVerificationContext 's ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I created a new target for you to use:
This will result in the server port being setup before the interaction is tested.
3.5.14 has been released