Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Only writes one interaction #67

Closed
surpher opened this issue May 13, 2021 · 2 comments
Closed

Bug: Only writes one interaction #67

surpher opened this issue May 13, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@surpher
Copy link
Owner

surpher commented May 13, 2021

馃寧 Environment

  • Xcode: 12.5
  • Platform: iOS and macOS
  • Version/Release: v0.4.0
  • Dependency manager: SPM and Carthage

馃挰 Description

When running Pact tests, the generated Pact contract only contains one interaction.

馃Χ Reproduction Steps

Steps to reproduce the behavior:

  1. Setup a project
  2. Write at least two Pact tests
  3. Run Pact tests

馃 Expected Results

Generated Pact contract contains all the interactions

馃槻 Actual Results

Generated Pact contract contains only one interaction

馃尦 Logs

See Pact-iOS-Spec2-Example project and test run at step:5:67.

馃搫 Stack Traces

Include a stack trace if applicable...

馃 Relationships

  • Related PRs or Issues: #xxx, #yyy
@surpher surpher added the bug Something isn't working label May 13, 2021
@surpher
Copy link
Owner Author

surpher commented May 13, 2021

MockService holds a mutable array of Interactions. When tests are run, mockService gets re-instantiated for each of the tests and nullifies the array. When sending it to PactSwiftMockServer to verify and write the Pact contract, any previously run tests are lost.

@surpher
Copy link
Owner Author

surpher commented May 13, 2021

A way to keep a reference to one instance of MockService is to wrap it in a singleton.
See README.md and pact-swift-examples.

A related issue has been identified in PactSwiftMockService package and resolved with https://github.com/surpher/PactSwift/releases/tag/v0.4.1.

@surpher surpher closed this as completed May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant