You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given an existing pact file for a specific consumer/provider
When running a pact consumer test for the same consumer/provider
I want the result of the second run to be merged into the existing pact file
So that i end up with one pact file describing all interactions
The pact-ffi interface int32_t pactffi_write_pact_file(int32_t mock_server_port, const char *directory, bool overwrite); already supports merge (by default) and overwriting a pact file.
Add a convenience init PactSwift.MockService.init(consumer: provider: scheme: writePactTo: overwrite:) with the optional overwrite argument set to false as to merge as a default,
Track the immutable state for overwrite in a private let (similar to pactsDirectory)
When creating a MockServer object when finalising the Pact tests (triggering pact-ffi to write the file) init it with overwrite parameter.
Access the immutable private let overwrite value in func dealing with pact-ffiwritePactContractFile(port: completion:)
A new version of PactSwiftMockServer and a generated XCFramework binary needed to vend via SPM
A new version of PactSwift
✅ Acceptance Criteria
GIVEN ... WHEN ... THEN ...
🚫 Out of Scope
The text was updated successfully, but these errors were encountered:
That's a good request. Thanks for raising it.
Indeed PactSwift is forcing an overwrite on each test run. pact-ffi already supports the merging of existing Pact files and the update to PactSwift and PactSwiftMockService should be an easy enough job. It just happens it needs code changes in two repos.
The Design part has been added to the issue and hopefully should be clear enough for someone to tackle it? Otherwise it will have to wait for a couple of weeks for me to pick it up.
In the mean time... The overwriting of Pact file should not keep you from keeping Pact tests for same consumer/provider in multiple files. You should be able to use inheritance and have a reference to your mockService singleton. You will still only end up only with the interactions for the tests you run. If you want all interactions written in the same file you need to run them all in one test run.
🗣 Context
We want to have pact tests in separate source files that describe interactions for the same consumer/provider
PactSwift seems to overwrite any existing pact file. It would be nice if there was an option that allows to merge with
an existing pact (similiar to the pact-jvm-consumer https://docs.pact.io/implementation_guides/jvm/consumer/junit#forcing-pact-files-to-be-overwritten-365)
💬 Narrative
Given an existing pact file for a specific consumer/provider
When running a pact consumer test for the same consumer/provider
I want the result of the second run to be merged into the existing pact file
So that i end up with one pact file describing all interactions
📝 Notes
🏗 Design
The
pact-ffi
interfaceint32_t pactffi_write_pact_file(int32_t mock_server_port, const char *directory, bool overwrite);
already supports merge (by default) and overwriting a pact file.PactSwift.MockService.init(consumer: provider: scheme: writePactTo: overwrite:)
with the optionaloverwrite
argument set tofalse
as to merge as a default,overwrite
in aprivate let
(similar topactsDirectory
)MockServer
object when finalising the Pact tests (triggeringpact-ffi
to write the file) init it withoverwrite
parameter.private let overwrite
value in func dealing withpact-ffi
writePactContractFile(port: completion:)
PactSwiftMockServer
and a generated XCFramework binary needed to vend via SPMPactSwift
✅ Acceptance Criteria
GIVEN ...
WHEN ...
THEN ...
🚫 Out of Scope
The text was updated successfully, but these errors were encountered: