Skip to content

Commit 48eff60

Browse files
michaelosthegetwiecki
authored andcommitted
Write instructions on running the test suite
1 parent 559969c commit 48eff60

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed
Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,47 @@
11
(running_the_test_suite)=
22
# Running the test suite
3+
The first step to run tests is the installation of additional dependencies that are needed for testing:
34

4-
TODO: explain steps to run test suite. This is a how to guide, so assume readers know how to install
5-
things and so on, at most mention what dependencies are needed.
5+
```bash
6+
pip install -r requirements-dev.txt
7+
```
8+
9+
The PyMC test suite uses `pytest` as the testing framework.
10+
If you are unfamiliar with `pytest`, check out [this short video series](https://calmcode.io/pytest/).
11+
12+
With the optional dependencies installed, you can start running tests.
13+
Below are some example of how you might want to run certain parts of the test suite.
14+
15+
```{attention}
16+
Running the entire test suite will take hours.
17+
Therefore, we recommend to run just specific tests that target the parts of the codebase you're working on.
18+
```
19+
20+
To run all tests from a single file:
21+
```bash
22+
pytest -v pymc/tests/test_model.py
23+
```
24+
25+
```{tip}
26+
The `-v` flag is short-hand for `--verbose` and prints the names of the test cases that are currently running.
27+
```
28+
29+
Often, you'll want to focus on just a few test cases first.
30+
By using the `-k` flag, you can filter for test cases that match a certain pattern.
31+
For example, the following command runs all test cases from `test_model.py` that have "coord" in their name:
632

733
```bash
8-
pip install pytest pytest-cov coverage
34+
pytest -v pymc/tests/test_model.py -k coord
35+
```
36+
937

10-
# To run a subset of tests
11-
pytest --verbose pymc/tests/<name of test>.py
38+
To get a coverage report, you can pass `--cov=pymc`, optionally with `--cov-report term-missing` to get a printout of the line numbers that were visited by the invoked tests.
39+
Note that because you are not running the entire test suite, the coverage will be terrible.
40+
But you can still watch for specific line numbers of the code that you're working on.
1241

13-
# To get a coverage report
14-
pytest --verbose --cov=pymc --cov-report term-missing pymc/tests/<name of test>.py
42+
```bash
43+
pytest -v --cov=pymc --cov-report term-missing pymc/tests/<name of test>.py
1544
```
45+
46+
When you are reasonably confident about the changes you made, you can push the changes and open a pull request.
47+
Our GitHub Actions pipeline will run the entire test suite and if there are failures you can go back and run these tests on your local machine.

0 commit comments

Comments
 (0)