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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of Matching Rules #221

Merged
merged 1 commit into from
Nov 29, 2024
Merged

Support of Matching Rules #221

merged 1 commit into from
Nov 29, 2024

Conversation

ludorival
Copy link
Owner

Overview

This pull request introduces enhancements to the pact-jvm-mockk library, focusing on adding support for request and response matching rules. These changes allow for more flexible contract definitions by enabling pattern-based matching rather than relying solely on exact values.

Key Changes

  1. README.md Updates:

    • Added a new section on configuring matching rules for requests and responses. This includes examples of using Matcher for headers and response bodies.
  2. Interface and Implementation Enhancements:

    • Updated InteractionBuilder and InteractionBuilderImpl to include methods for defining request and response matching rules using a MatchingRulesBuilder.
  3. New Classes:

    • Introduced Matcher and MatchingRulesBuilder classes to facilitate the creation of matching rules.
  4. Pact Data Model Updates:

    • Modified the Pact.Interaction.Request and Pact.Interaction.Response data classes to include a matchingRules property.
  5. Serialization Improvements:

    • Updated Utils.kt to ensure non-null fields are included in JSON serialization by default.
  6. Test Enhancements:

    • Updated test cases in NonDeterministicPact.kt and ShoppingServiceContracts.kt to utilize the new matching rules functionality.
  7. Pact Files:

    • Updated pact files to reflect the new matching rules, removing unnecessary null fields and adding matching rules for headers and response bodies.

Benefits

  • Flexibility: Allows for more dynamic contract testing by supporting pattern-based matching.
  • Clarity: Improves documentation and examples for users to understand and implement matching rules.
  • Efficiency: Reduces the need for exact value matching, simplifying test maintenance.

Testing

  • All existing tests have been updated to use the new matching rules.
  • New tests have been added to verify the functionality of request and response matching rules.

Additional Notes

  • Ensure that all dependencies are up-to-date to support the new features.
  • Review the updated documentation in README.md for guidance on using the new matching rules.

@ludorival ludorival merged commit 5037c9d into main Nov 29, 2024
2 checks passed
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.

1 participant