Skip to main content

Generate Python test cases from Pact files, for easier provider verification.

Project description

Pact Test Generator

https://img.shields.io/pypi/v/pact-testgen.svg https://img.shields.io/travis/pymetrics/pact-testgen.svg Documentation Status

Generate Python test cases from Pact files, for easier provider verification.

Features

  • Test Pact contracts against your Python providers via unit tests. Get test isolation for free.

  • pact-testgen creates test cases from your Pact files, with placeholders for defining provider states.

Getting Started

Install with pip

python -m pip install pact-testgen

Generate test files

Generate a provider_states.py and test_pact.py files in your tests directory:

pact-testgen /path/to/pactfile.json /tests/dir

For more details, see the Usage section of the documentation.

Fill in the generated provider states file

In your tests directory (passed as the second argument to pact-testgen), you’ll see a file named provider_states.py. It will contain set up functions matching the provider states defined in your pact file.

Before continuing, complete these functions so that they create the required states.

Run your tests

Run your test suite as normal, being sure to check the the test runner has picked up your new test_pact.py file.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Logo Admiranda Urbis Venetæ from the British Library’s King’s Topographical Collection.

Verification of test responses in generated test code is powered by pactman.

History

0.1.0 (2021-08-12)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pact_testgen-0.1.0.tar.gz (187.4 kB view hashes)

Uploaded Source

Built Distribution

pact_testgen-0.1.0-py2.py3-none-any.whl (10.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page