Skip to content

Latest commit

 

History

History
115 lines (76 loc) · 3.14 KB

README.rst

File metadata and controls

115 lines (76 loc) · 3.14 KB

Tests

Software without tests is broken by design.

https://painless.software/writing-tests

Philosophy

No need to install additional packages for running tests

All dependencies for running your tests are specified in tox.ini

Tox will create virtual environments and install those packages automagically when running your tests.

Working with Tox

Install Tox on your local machine:

pip install tox

Use the tox command in the terminal to run your tests locally:

# list all available test environments (= Tox targets)
tox -lv
# run all tests against all environments
tox
# run a specific set of tests (one or several)
tox -e py38
tox -e flake8,pylint
# remove all environments, build files and folders
tox -e clean

If you need to use command line options for a command separate them with a double-dash, like so:

tox <tox args> -- <command args>

Examples:

tox -e py38 -- -vv --exitfirst
tox -e behave -- --stop
tox -e behave -- --format=pretty
tox -e behave -- --tags=-docker
tox -e flake8 -- --help

Linting and Unit Tests

We use Tox to run our entire tests suite, including all supported Python versions. You may want to use pyenv to install all Python versions locally. Alternatively, you can test only against the versions you already have installed on your machine as follows, wait for the build servers to cover the missing ones, and fix identified issues (if any) with additional commits:

tox -e flake8,pylint,py38

Field Tests

We have field tests to generate and deploy an example project from your local working version. In order to run the deployment, you need to have access to the GitLab repository of your target generated project (such as example django), and you need to generate a Personal Access Token on GitLab. (Top-right user menu > Settings > Access Tokens)

export GITLAB_API_TOKEN=<your personal access token>
tox -e clean,fieldtest django

Generated files are found in /tmp/painless-generated-projects

Running Docker in Tests

Tests that require Docker must be run locally on your developer machine, because not all CI servers allow running Docker (inside Docker) on their infrastructure. In behave tests the related scenarios are tagged with @docker. Run them with:

tox -e behave -- --tags=docker