question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pact Provider Exception when no pacts to verify

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
uglyogcommented, Mar 21, 2020

@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.

1reaction
fragonibcommented, May 27, 2022

Bad news 😦 It doesn´t work when template method has also an HttpRequest parameter

    @TestTemplate
    @ExtendWith(PactVerificationSpringProvider.class)
    void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) throws ProtocolException {
        removeContextFromRequestPath(request);
        context.verifyInteraction();
    }

It throws

org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.apache.hc.core5.http.HttpRequest request] in method [pactVerificationTestTemplate(au.com.dius.pact.provider.junit5.PactVerificationContext,org.apache.hc.core5.http.HttpRequest) throws org.apache.hc.core5.http.ProtocolException].

When this HttpRequest is removed logs expected No pact found to verify

Any thoughts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pact Provider Exception when no pacts to verify #768 - GitHub
This is a problem with JUnit 5. The pact library is doing the correct thing, but then as there are no pacts, there...
Read more >
No Pact files were found to verify - Stack Overflow
I tried to rename the provider in publisher side and use it with new name, still same issue. Pacts on server: enter image...
Read more >
Pact junit runner | Pact Docs
By default, the pact runner will verify all pacts for the given provider. You can filter the pacts and interactions by the following...
Read more >
PACT JVM Example | ArXmanS
Publish Pacts to Pact Broker; 2.4. Run the Contract Test at Provider side. 3. Gradle Configuration; 4. Contract Test between Provider and Consumer...
Read more >
Consumer Tests with Pact, Junit5, SpringBoot - Level Up Coding
This verification is provided by the Pact framework, and allows independent testing of the consumer and provider without having to integrate both together....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found