@PactBroker(scheme = "https", host = "${pactbroker.host}", authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}"))
@Provider("PriceService")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@ExtendWith(SpringExtension.class)
public class PriceServicePactTests {
@LocalServerPort
private final int port = 8082;
ObjectMapper objectMapper = new ObjectMapper();
@MockBean
private PriceDAO priceDao;
@BeforeEach
public void setupTest(final PactVerificationContext context) {
// TODO Catch enviroment variable
System.setProperty("pact.provider.tag", "dev");
// TODO Get version from project properties
System.setProperty("pact.provider.version", "1.0.0");
context.setTarget(new HttpTestTarget("localhost", port, "/"));
}
@BeforeClass
public void enablePublishingPact() {
System.setProperty("pact.verifier.publishResults", "true");
}
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void pactVerificationTestTemplate(final PactVerificationContext context) {
context.verifyInteraction();
}
I'm using this dependency on provider:
<!-- https://mvnrepository.com/artifact/au.com.dius/pact-jvm-provider-junit5 -->
<dependency>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-junit5</artifactId>
<version>4.0.10</version>
</dependency>
When I run the test I got the error: java.lang.RuntimeException: Could not resolve property "pactbroker.host" in the system properties or environment variables and no default value is supplied