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.

[PactNet 4.0.0-beta.1] PublishResults options raising an exception

See original GitHub issue

A very basic example like this throws an exception with when publishing results

    [Fact]
    public void VerifyLatestPacts()
    {
        string version = Environment.GetEnvironmentVariable("VERSION");
        string branch = Environment.GetEnvironmentVariable("BRANCH");
        string buildUri = Environment.GetEnvironmentVariable("BUILD_URL");

        var config = new PactVerifierConfig
        {
            LogLevel = PactLogLevel.Information,
            Outputters = new List<IOutput>
            {
                new XUnitOutput(this.output)
            }
        };

        IPactVerifier verifier = new PactVerifier(config);

        verifier.ServiceProvider("My Provider", this.fixture.ServerUri)
                .WithPactBrokerSource(new Uri("https://broker.example.org"), options =>
                {
                    options.ConsumerVersionSelectors(new ConsumerVersionSelector { MainBranch = true, Latest = true })
                           .PublishResults(version, results =>
                           {
                               results.ProviderBranch(branch)
                                      .BuildUri(new Uri(buildUri));
                           });
                })
                .WithProviderStateUrl(new Uri(this.fixture.ServerUri, "/provider-states"))
                .Verify();
    }
}

Error

  Failed API.Tests.ProductApiContractVerificationTests.EnsureProductApiHonorsPactWithOrderServiceConsumer [118 ms]
  Error Message:
   System.ArgumentNullException : Value cannot be null. (Parameter 'source')
  Stack Trace:
     at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at PactNet.Verifier.InteropVerifierProvider.SetPublishOptions(String providerVersion, Uri buildUrl, ICollection`1 providerTags, String providerBranch)
   at PactNet.Verifier.PactBrokerPublishOptions.Apply()
   at PactNet.Verifier.PactBrokerOptions.PublishResults(String providerVersion, Action`1 configure)
   at API.Tests.ProductApiContractVerificationTests.<EnsureProductApiHonorsPactWithOrderServiceConsumer>b__1_0(IPactBrokerOptions options) in C:\pact-workshop\pact_ffi-product-provider\tests\ProductApiContractVerificationTests.cs:line 70
   at PactNet.Verifier.PactVerifierProvider.WithPactBrokerSource(Uri brokerBaseUri, Action`1 configure)
   at API.Tests.ProductApiContractVerificationTests.EnsureProductApiHonorsPactWithOrderServiceConsumer() in C:\pact-workshop\pact_ffi-product-provider\tests\ProductApiContractVerificationTests.cs:line 67

Test Run Failed.

adding the .ProviderTags("stage"); option seems mandatory

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
adamrodgercommented, Feb 16, 2022

Ah, that’s gonna be missing an Array.Empty when something is calling into the interop code.

We definitely need better coverage using a real pact broker in integration tests. One thing that makes that a bit tricky is that different broker versions support different options, and it’s not really clear what the support policy of the broker is.

0reactions
bethesquecommented, Jul 14, 2022

The issue closes automatically when I mention it in a commit message

This is so annoying! I wish they’d only close it when the commit was tagged in a release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow Pact Verifier with Pact Broker Source to publish ...
Hi. I am currently migrating a codebase to PactNet v4 Beta versions and would like to publish the Verification results to a pact...
Read more >
Pact Maven plugin | Pact Docs
This is a Maven plugin for verifying pacts against a running provider, publishing pacts generated by consumer tests,
Read more >
has joined #protobufs - Pact (Contract Testing)
I was thinking that it would be possible to add an intermediate layer between the language-specific client and the (currently Ruby) mock server...
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