From 802b499b679f0292cd3d2c87b89822746c5f20ad Mon Sep 17 00:00:00 2001 From: Jordan Cook Date: Thu, 1 Apr 2021 10:52:52 -0500 Subject: Add an example test runner script, and add some more testing info to docs --- CONTRIBUTING.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'CONTRIBUTING.md') diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6b2e7e6..80303fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,6 +37,8 @@ $ pre-commit uninstall ``` ## Testing + +### Test Layout * Tests are divided into unit and integration tests: * Unit tests can be run without any additional setup, and don't depend on any external services * Integration tests depend on additional services, which are easiest to run using Docker @@ -44,9 +46,16 @@ $ pre-commit uninstall * See [conftest.py](https://github.com/reclosedev/requests-cache/blob/master/tests/conftest.py) for [pytest fixtures](https://docs.pytest.org/en/stable/fixture.html) that apply the most common mocking steps and other test setup. + +### Running Tests +* Run `pytest` to run all tests +* Run `pytest tests/unit` to run only unit tests +* Run `pytest tests/integration` to run only integration tests +* Run `./runtests.sh` to run all tests with some useful options for test coverage reports, + multiprocessing, and debugging. ### Integration Tests -Local databases are required to run integration tests, and docker-compose config is included to make +Live databases are required to run integration tests, and docker-compose config is included to make this easier. First, [install docker](https://docs.docker.com/get-docker/) and [install docker-compose](https://docs.docker.com/compose/install/). @@ -56,6 +65,16 @@ $ docker-compose up -d pytest tests/integration ``` +## Debugging +When you run into issues while working on new features and/or tests, it will make your life much easier +to use a debugger instead of haphazard `print` statements. Most IDEs have a built-in debugger, but if +you prefer the command line, [ipdb](https://github.com/gotcha/ipdb) is a good option. To install: +```bash +pip install ipython ipdb +``` + +The `runtests.sh` script will use ipdb by default, if it's installed. + ## Documentation [Sphinx](http://www.sphinx-doc.org/en/master/) is used to generate documentation. -- cgit v1.2.1