Hi There, I am writing the pact provider test on t...
# pact-broker
p
Hi There, I am writing the pact provider test on the application running with Spring and Junit 4. I am using the au.com.dius.pact.provider dependenc and came across 2 questions and it will be really appreciated anyone can guide on this 1. What I understand from the documentation is while doing provider testing we need to test against the actual server in test. And I am using a docker container hosted with application and hitting the pact provider test against the application in testing container. The situation I came across is the base url("127.0.0.1"), port (443) and protocol (https) can vary and I need this values to be passed from some environment variables in the CI pipeline. Can anyone guide on this
Copy code
@TestTarget
public final Target target = new HttpTarget("https", "127.0.0.1", 443, "api", true);
2. I have a job in the pipeline which build the application by running the "mvn clean install" command . The provider test also runs in this scenario and as the environment is not ready it will fail the test and build will not succeed. I want to control the running of pact provider test only when invoked individually in a job for pact provider testing. In all the other cases if anyone invoke the command "mvn clean install" pact provider test cases should not run. How to handle this situation. Thanks in advance for the help and guidance (edited)
u
These are JUnit and Maven questions, not really Pact ones. Junit supports ways of tagging tests, so you can exclude them based on certain conditions. I would also suggest upgrading to JUnit 5, it will help with your first question.
p
Thanks, @uglyog for the answer. The reason I need to use Junit 4 is that the current application is a heavy monolithic application and has many test cases. Migrating it to junit 5 involves lots of effort. Is there a way we can achieve Question 1 using Junit 4 @testtarget
u
You can run JUnit 4 and Junit 5 together, you don't have to migrate all your tests
You can try initialise the parameters using
System.getenv
, but there is no direct support for doing that