zun/doc/source/contributor/unit-tests.rst
Hongbin Lu 9a13755cbe List system dependencies for running common tests
Add an bindep.txt file containing a cross-platform list of
dependencies needed for running included tox-based tests. Also include a
tox environment for convenience calling the bindep[*] utility to list
any missing system requirements.

For bindep.txt see also
http://docs.openstack.org/infra/manual/drivers.html#package-requirements

[*] http://docs.openstack.org/infra/bindep/

Change-Id: I7fff1f20d50eacc4eb2f0b0f6f24ba521f5df5f7
2018-10-22 03:31:40 +00:00

2.1 KiB

Run unit tests

This is a guide for developers who want to run unit tests in their local machine.

Prerequisite

Zun source code should be pulled directly from git:

# from your home or source directory
cd ~
git clone https://git.openstack.org/openstack/zun
cd zun

Install the prerequisite packages listed in the bindep.txt file.

On Debian-based distributions (e.g., Debian/Mint/Ubuntu):

# Ubuntu/Debian (recommend Ubuntu 16.04):
sudo apt-get update
sudo apt-get install python-pip
sudo pip install tox
tox -e bindep
sudo apt-get install <indicated missing package names>

On Fedora-based distributions (e.g., Fedora/RHEL/CentOS/Scientific Linux):

sudo yum install python-pip
sudo pip install tox
tox -e bindep
sudo yum install <indicated missing package names>

On openSUSE-based distributions (SLES 12, openSUSE Leap 42.1 or Tumbleweed):

sudo zypper in python-pip
sudo pip install tox
tox -e bindep
sudo zypper in <indicated missing package names>

Running the tests

All unit tests should be run using tox. To run Zun's entire test suite:

# run all tests (unit and pep8)
tox

To run a specific test, use a positional argument for the unit tests:

# run a specific test for Python 2.7
tox -epy27 -- test_container

You may pass options to the test programs using positional arguments:

# run all the Python 2.7 unit tests (in parallel!)
tox -epy27 -- --parallel

To run only the pep8/flake8 syntax and style checks:

tox -epep8