liveBook · Manning

Matching branch rule

As explained in Contract Testing in Action

A matching branch rule is a Pact selection rule that requires provider verification to use a consumer contract from a branch with the corresponding name.

When consumer and provider teams develop the same feature, matching branch names let the provider verify the consumer contract for that feature before either team merges. In Pact, enabling the matching branch rule makes provider verification select the consumer contract whose branch matches the provider branch. A provider can also verify the consumer’s main-branch contract in the same run, combining feature confidence with protection against regressions on the shared baseline. section 10.2.2

Configure the workflow by:

  • Publishing consumer versions with their Git commit and branch metadata. section 10.2.2
  • Setting matchingBranch to true in consumerVersionSelectors. section 10.2.2

Feature branch verification

If the consumer branch is test-pact-features, the provider uses the same branch name and verifies both that contract and the consumer’s main-branch contract. The MoviesAPI provider can then validate the feature integration without losing baseline coverage.

How Contract Testing in Action covers it

How deep it goes
Defines matchingBranch and demonstrates selector configuration, branch metadata, and local verification.
Examples
Uses test-pact-features, WebConsumer, MoviesAPI, and simultaneous main-branch and matching-branch contracts.
What it assumes
Assumes consumer and provider teams use shared branch names and record Git commit and branch metadata.
What you can do after
Operate/configure Pact verification to select contracts from matching feature branches and the main branch.
How it connects
Connects Pact contract testing with consumer version selectors, provider verification, Git branches, and CI/CD.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Contract Testing in Action. The section links point to the parts of the book it draws on.