pact-jvm: Pact Provider Exception when no pacts to verify
Hello,
I’m implementing Pact Provider Junit5 and I’m facing this issue whenever there is no pacts available to verify for this provider (when there is, it works like a charm). I’m using version 3.5.21.
This is the implementation :
@Provider("myprovider")
@PactBroker(host="${pact.broker.host}", port = "${pact.broker.port}",tags = "${pact.broker.tag}")
@IgnoreNoPactsToVerify
public class PactVerifyITTest {
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void testTemplate(Pact pact, Interaction interaction, HttpRequest request, PactVerificationContext context) {
context.verifyInteraction();
}
And the exception raised when not pacts are available:
...
16:11:11.110 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "{"_links":{"self":{"href":"http://192.168.99.100:30003/pacts/provider/myprovider/latest/dev","title":"Latest pact versions for the provider myprovider with consumer version tag 'dev'"},"provider":{"href":"http://192.168.99.100:30003/pacticipants/myprovider","title":"myprovider"},"pb:pacts":[],"pacts":[]}}"
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << HTTP/1.1 200 OK
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Content-Type: application/hal+json;charset=utf-8
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Content-Length: 322
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Connection: keep-alive
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Status: 200 OK
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Date: Tue, 11 Sep 2018 14:10:53 GMT
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << X-Content-Type-Options: nosniff
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Server: Webmachine-Ruby/1.5.0 Rack/1.3
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << X-Pact-Broker-Version: 2.23.3
16:11:11.110 [main] DEBUG org.apache.http.headers - http-outgoing-1 << X-Powered-By: Phusion Passenger 5.1.11
16:11:11.110 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
16:11:11.111 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection [id: 1][route: {}->http://192.168.99.100:30003] can be kept alive indefinitely
16:11:11.111 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-1: set socket timeout to 0
16:11:11.111 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 1][route: {}->http://192.168.99.100:30003][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]
org.junit.platform.commons.util.PreconditionViolationException: No supporting TestTemplateInvocationContextProvider provided an invocation context
Did I miss something possibly? or is it an issue ? Thanks
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (7 by maintainers)
Commits related to this issue
- feat: use a dummy test for JUnit 5 tests with IgnoreNoPactsToVerify annotation #768 — committed to pact-foundation/pact-jvm by deleted user 4 years ago
- feat: updated JUnit 5 readmne about IgnoreNoPactsToVerify annotation #768 — committed to pact-foundation/pact-jvm by deleted user 4 years ago
@ahsankarimbhai the context will be null when there are no pacts, because the context is created from the pact files. Just check for not null before using the context.
Bad news 😦 It doesn´t work when template method has also an
HttpRequestparameterIt throws
When this
HttpRequestis removed logs expectedNo pact found to verifyAny thoughts?
Suggstion: Make (in Kotlin case) parameters nullable so pact lib can pass nulls?
Test modification:
Will there still be problem with context values?