Hey all, I am writing a simple provider test with ...
# pact-jvm
a
Hey all, I am writing a simple provider test with
Copy code
"au.com.dius.pact.provider:junit5:4.1.39"
I have specified
@PactFolder("src/contractTest/")
but the test fails with the following error
Copy code
1.1) Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
It fails on
context.verifyInteraction();
under
Copy code
@TestTemplate
    @ExtendWith(PactVerificationInvocationContextProvider.class)
    void testTemplate(PactVerificationContext context) {
        context.verifyInteraction();
    }
I am trying to understand why it is making the call to localhost when I have specified a local path under @PactFolder annotation. Can anyone help?
m
You need to specify a target of the provider test - i.e. where the running provider is to test the contracts against. As you haven't specified one it's using the default
Check out the docs/examples for how to specify the location of your provider
a
Could you point me to an example that has this setup? Thank you.
m
Howtoexamples
s
m
Or the JVM docs at docs.pact.io
a
I did go through them once but I'll look more. Thanks.
👍 1
Looks like I have to specify the test target (from docs-> )
Copy code
@BeforeEach
  void before(PactVerificationContext context) {
    context.setTarget(HttpTestTarget.fromUrl(new URL(myProviderUrl)));
    // or something like
    // context.setTarget(new HttpTestTarget("localhost", myProviderPort, "/"));
  }
Does that mean I have to serve my contract file just for pact to verify? 🤔
m
In not sure what you mean sorry
You need to start the provider locally, and then point test target at the provider
Pact needs to check your provider is compatible with the contract
👍 1
a
I didn't start it locally. I will try that. Thank you.
m
👍