Skip to content

Generate unit tests for provider validation of Pact API contracts.

License

Notifications You must be signed in to change notification settings

pymetrics/pact-testgen

Repository files navigation

Pact Test Generator

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 /tests/dir -f /path/to/pactfile.json

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

Fill in the generated provider states file

In your tests directory (passed as the first 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.

About

Generate unit tests for provider validation of Pact API contracts.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •