Skip to content

Conversation

@YOU54F
Copy link
Member

@YOU54F YOU54F commented Apr 25, 2023

  • Updates to Pact-Net latest version 4.5.0 🚀
  • Updates to use branches and record-deployments/environments over tags

notes

Traditionally we wouldn't recommend committing pacts to source control, and explicitly ignore it in more repos, however it is nice to see the delta between the latest ruby backed pact-net (3.0.2) and the latest rust backed pact-net (4.5.0)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove the consumer class fixture, that was responsible for setting up the ruby backed lifecycle methods

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="PactNet" Version="4.5.0" />
<PackageReference Include="PactNet.Output.Xunit" Version="1.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated deps for pact-net 4.5.0

LogLevel = PactLogLevel.Debug
};

pact = Pact.V3("pactflow-example-consumer-dotnet", "pactflow-example-provider-dotnet", Config).WithHttpInteractions(port);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than calling our ConsumerPactClassFixture we setup our provider in test.

.WithHeader("Content-Type", "application/json; charset=utf-8")
.WithJsonBody(new TypeMatcher(products));

await pact.VerifyAsync(async ctx =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wrap our system under test ProductClient().GetProducts(...) inside a VerifyAsync block.

This starts our Pact.V3(...) mock provider, and can give us access to a dynamically created URL/Port if required.

We then perform our assertions on our result from our consumer method GetProducts(...) rather than on the expected Providers response. This is the traditional unit testing style, and ensures you are testing consumer behaviour rather than providers implementation detail

@YOU54F YOU54F merged commit e6c73e7 into master Apr 25, 2023
@JP-Ellis JP-Ellis deleted the dotnet6_pactnet450 branch April 21, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants