It seems this was also an issue a few years ago and it appears to be back. I have a small pact.io demo project I am using to wire everything together. However I keep running into this error. I think there is a dependency missing but I have all the recommended dependencies.
java.lang.IllegalArgumentException: Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.
pom.xml
<!-- ================================================================= -->
<!-- Pact.io -->
<!-- ================================================================= -->
<dependency>
<groupId>au.com.dius.pact.consumer</groupId>
<artifactId>junit5</artifactId>
<version>4.6.10</version>
</dependency>
<dependency>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>junit5</artifactId>
<version>4.6.10</version>
</dependency>
<dependency>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-junit_2.11</artifactId>
<version>3.5.24</version>
</dependency>
Provider
@PactBroker
@PactFolder("pacts")
@Provider("search_provider")
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class ProviderTest {
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void pactVerificationTestTemplate(PactVerificationContext context) throws IOException {
context.verifyInteraction();
}
}
consumer
@PactConsumerTest
@PactTestFor(providerName = "search_provider")
class ConsumerTest {
@Pact(provider="search_provider", consumer="test_consumer")
public RequestResponsePact createPact(PactDslWithProvider builder) {
return builder
.given("test state")
.uponReceiving("Example of test interactions")
.path("/products")
.method("GET")
.willRespondWith()
.status(200)
.body("{"responsetest": true}")
.toPact();
}
}
application.yaml which is added in main and test.
pactbroker:
host: https://pact-broker.qmtools.app.schwarz:8443/