Closed cetk closed 7 months ago
Did you mean to raise the issue over here: https://github.com/pact-foundation/pact-net/
yes
Moving issue to the correct repo.
Could you please perhaps demonstrate (via code) how you construct your Pact tests so that we can better understand?
You are also running quite an old version (3.0.0). Probably, you might just need to ensure you're calling the correct lifecycle method to write the pacts to file as you go.
If you're new to Pact, I'd suggest upgrading to the latest version.
the example above helps..it does have all tests published in same pact file, but I don't see any specific settings for the same. Is the latest version supports it ?
PactNet 4.x+ (which is the only supported version) works in merge mode only, thus running tests will always add to an existing file instead of overwriting it. This wasn't the case with v3.x and less, which are all unsupported versions now.
I see the builder has persisting pact file which keeps all interactions in single pact json. I have got one more question, how do I send request body with object with inner objects for pact test like
_mockProviderService.UponReceiving("a request to create a new event") .With(new ProviderServiceRequest { Method = HttpVerb.Post, Path = "/events", Headers = new Dictionary<string, object> { { "Content-Type", "application/json; charset=utf-8" } }, Body = new { eventId, eventType = "DetailsView", timestamp = new TimeObject { date = "2024-02-25 21:38:57.290" } } }) .WillRespondWith(new ProviderServiceResponse { Status = 201 });
Software versions
I'm writing Pact tests as part of a C# .NET application with NUnit test system. I have several functions that each run a Pact test. They overwrite the previous functions pact definition such that my final pact.json only has the last run test. How do I have separate test functions that all append to the pact test?
Steps to reproduce
Provide a repository, gist or reproducable code snippet so that we can test the problem. You may also want to adapt one of the examples in the repository to demonstrate the problem.
Relevent log files
Please ensure you set logging to
DEBUG
and attach any relevant log files here (or link from a gist).