I'm doing a POC for CDC testing using Pactman and pact-python . I'm able to generate pact files and to verify the pacts with provider Base url without registering to pact broker, i'm using following approach.It will check for any failures, will it be the best practice or I need to use the broker?
import re
result = []
win_cmd = 'pact-verifier --provider-base-url=https://jsonplaceholder.typicode.com --pact-url=./src/Consumer-Provider-pact.json'
process = subprocess.Popen(win_cmd,
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE )
for line in process.stdout:
#print(line)
result.append(line)
status = re.split('failure|failures',str(result))[-2].split(',')[-1]
if int(status) == 0:
print('success')
See https://docs.pact.io/pact_broker/#why-do-i-need-one
You can achieve the pact generation and verification steps without a Pact Broker, however, you will not be able to realise the full benefits of using Pact for contract testing without a broker. The main two things you'll miss out on are:
The Pact Broker allows you to build pact into your release pipeline. However, if you are just getting started, try getting a pipeline working without one, and see how you go. When you are ready to try the more advanced stuff, start using one.
Read the Effective Pact set up guide to learn how to incrementally add Pact into your CI/CD pipeline.