# Testing and Coverage

# Pytest

We use pytest as our test runner.

It also supports Django unittest classes

You can check tests code in django_app/tests

# run tests
$ pytest django_app/tests/unittest --numprocesses 2

# Tests Structure

├── conftest.py
├── tests
│   ├── integration         # contains integration tests
│   └── unittest            # contains unit tests

# Integration Tests

Even you can use The test client to make sure the Django view works as expected, it can not promise the Javascript can work with Django without issue.

That is why we need Integration Tests in some cases.

In Django community, people usually choose selenium, but in SaaS Hammer, I recommend people to use Playwright instead.


  1. Playwright is very fast, and supports multiple programming languages.
  2. Playwright also supports parallel testing, which means, we can launch parallel testing in the CI for shorter execution time.
  3. Playwright has clean API, strong team and active community.
  4. SaaS Hammer already import and config Playwright as our integration testing solution.

# Coverage

We use pytest-cov to help us collect coverage data and generate coverage report.