James E. Blair | 9ab8662 | 2013-07-02 11:23:46 -0700 | [diff] [blame] | 1 | =========================== |
| 2 | Testing Your OpenStack Code |
| 3 | =========================== |
| 4 | ------------ |
| 5 | A Quickstart |
| 6 | ------------ |
| 7 | |
| 8 | This is designed to be enough information for you to run your first tests. |
| 9 | Detailed information on testing can be found here: https://wiki.openstack.org/wiki/Testing |
| 10 | |
| 11 | *Install pip*:: |
| 12 | |
| 13 | [apt-get | yum] install python-pip |
| 14 | More information on pip here: http://www.pip-installer.org/en/latest/ |
| 15 | |
| 16 | *Use pip to install tox*:: |
| 17 | |
| 18 | pip install tox |
| 19 | |
| 20 | Run The Tests |
| 21 | ------------- |
| 22 | |
| 23 | *Navigate to the project's root directory and execute*:: |
| 24 | |
| 25 | tox |
| 26 | Note: completing this command may take a long time (depends on system resources) |
| 27 | also, you might not see any output until tox is complete. |
| 28 | |
| 29 | Information about tox can be found here: http://testrun.org/tox/latest/ |
| 30 | |
| 31 | |
| 32 | Run The Tests in One Environment |
| 33 | -------------------------------- |
| 34 | |
| 35 | Tox will run your entire test suite in the environments specified in the project tox.ini:: |
| 36 | |
| 37 | [tox] |
| 38 | |
| 39 | envlist = <list of available environments> |
| 40 | |
| 41 | To run the test suite in just one of the environments in envlist execute:: |
| 42 | |
| 43 | tox -e <env> |
| 44 | so for example, *run the test suite in py26*:: |
| 45 | |
| 46 | tox -e py26 |
| 47 | |
| 48 | Run One Test |
| 49 | ------------ |
| 50 | |
| 51 | To run individual tests with tox:: |
| 52 | |
| 53 | tox -e <env> -- path.to.module.Class.test |
| 54 | |
| 55 | For example, to *run the basic Zuul test*:: |
| 56 | |
| 57 | tox -e py27 -- tests.test_scheduler.TestScheduler.test_jobs_launched |
| 58 | |
| 59 | To *run one test in the foreground* (after previously having run tox |
| 60 | to set up the virtualenv):: |
| 61 | |
| 62 | .tox/py27/bin/python -m testtools.run tests.test_scheduler.TestScheduler.test_jobs_launched |
| 63 | |
James E. Blair | dda6c91 | 2013-07-29 14:12:12 -0700 | [diff] [blame] | 64 | List Failing Tests |
| 65 | ------------------ |
| 66 | |
| 67 | .tox/py27/bin/activate |
| 68 | testr failing --list |
| 69 | |
James E. Blair | 6c358e7 | 2013-07-29 17:06:47 -0700 | [diff] [blame] | 70 | Hanging Tests |
| 71 | ------------- |
| 72 | |
| 73 | The following will run each test in turn and print the name of the |
| 74 | test as it is run:: |
| 75 | |
| 76 | . .tox/py27/bin/activate |
| 77 | testr run --subunit | subunit2pyunit |
| 78 | |
| 79 | You can compare the output of that to:: |
| 80 | |
| 81 | python -m testtools.run discover --list |
| 82 | |
James E. Blair | 9ab8662 | 2013-07-02 11:23:46 -0700 | [diff] [blame] | 83 | Need More Info? |
| 84 | --------------- |
| 85 | |
| 86 | More information about testr: https://wiki.openstack.org/wiki/Testr |
| 87 | |
| 88 | More information about nose: https://nose.readthedocs.org/en/latest/ |
| 89 | |
| 90 | |
| 91 | More information about testing OpenStack code can be found here: |
| 92 | https://wiki.openstack.org/wiki/Testing |