Search code examples
c#pactpact-net

PactNet - How can I run multiple Pact json in the same test run?


I started learning Pact via a tutorial that used a single .json file that tested a basic API interaction. Now I want to start organising my PACTs by splitting them into multiple JSON files.

When setting up the Pact Verifier is there a way to specify the PactUri as a folder path rather than a path to a JSON?

This is what my verifier looked like originally:

IPactVerifier pactVerifier = new PactVerifier(config);
pactVerifier.ProviderState($"{_pactServiceUri}/provider-states")
            .ServiceProvider("Provider", _providerUri)
            .HonoursPactWith("Consumer")
            .PactUri(@"..\..\..\..\pacts\my-single-pact.json")
            .Verify();

I understand that the following cannot work as the PactUri() expects a file uri.

.PactUri(@"..\..\..\..\pacts")

.PactUri(@"..\..\..\..\pacts\*.json")

Solution

  • I asked the same question at the Pact forum in Github. This feature is supported by the underlying CLI but it's not offered in PactNet.