Skip to content

Commit

Permalink
Merge branch 'master' into text-based-exec
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Apr 1, 2020
2 parents 4085db1 + f07f225 commit 2ffaa69
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/develop/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,36 @@ Merging pull requests: There are three ways of 'merging' pull requests on GitHub
[rtd-link]: https://myst-parser.readthedocs.io/en/latest/?badge=latest
[black-badge]: https://img.shields.io/badge/code%20style-black-000000.svg
[black-link]: https://github.com/ambv/black

## Unit Testing

Testing is one of the most important aspects of your PR. You should write test cases and verify your implementation by following the testing guide above. If you modify code related to existing unit tests, you must run appropriate commands and confirm that the tests still pass.

Note that we are using [pytest](https://docs.pytest.org/en/latest/) for testing, [pytest-regression](https://pytest-regressions.readthedocs.io/en/latest/) to self-generate/re-generate expected outcomes of test and [pytest-cov](https://pytest-cov.readthedocs.io/en/latest/) for checking coverage.

To run tests along with coverage:

```
pytest -v --cov=myst_nb
```

To run tests along with generation of an html coverage report:

```
pytest -v --cov=myst_nb --cov-report=html
```


### Test File and Directory Naming Conventions

Tests are found in the [tests](https://github.com/ExecutableBookProject/MyST-NB/tree/master/tests) directory. In order for `pytest` to find the test scripts correctly, the name of each test script should start with `test_` prefix.

### How to Write Tests

There are many examples of unit tests under the [tests](https://github.com/ExecutableBookProject/MyST-NB/tree/master/tests) directory, so reading some of them is a good and recommended way. Prefer using the `fixtures` and the classes defined in [conftest.py](https://github.com/ExecutableBookProject/MyST-NB/blob/master/tests/conftest.py) as much as possible.

If using [pytest-regression](https://pytest-regressions.readthedocs.io/en/latest/), a new directory with `test_` prefix is expected to be created in the first test run. This will store your expected output against which subsequent test outputs will be compared.

### Code Coverage report

[pytest-cov](https://pytest-cov.readthedocs.io/en/latest/) is used to generate code coverage report. Make sure that your test cases cover most of the code written by you. Expect the coverage build in Travis CI to fail if the overall coverage of the repository decreases.

0 comments on commit 2ffaa69

Please sign in to comment.