Added all common modules in conductor directory
[optf/has.git] / conductor / conductor / tests / testing-overview.txt
1 Conductor testing
2 -----------------
3
4 All unit tests are to be placed in the conductor/tests directory,
5 and tests might be organized by tested subsystem. Each subsystem directory
6 must contain a separate blank __init__.py for test discovery to function.
7
8 An example directory structure illustrating the above:
9
10 conductor/tests
11 |-- engine
12 |   |-- __init__.py
13 |   |-- test1.py
14 |   |-- test2.py
15 |   |-- test3.py
16 |-- __init__.py
17 |-- test_plan.py
18
19 If a given test has no overlapping requirements (variables or same
20 routines) a new test does not need to create a subdirectory under the
21 test type.
22
23 Implementing a test
24 -------------------
25
26 testrepository - http://pypi.python.org/pypi/testrepository is used to
27 find and run tests, parallelize their runs, and record timing/results.
28
29 If new dependencies are introduced upon the development of a test, the
30 test-requirements.txt file needs to be updated so that the virtual
31 environment will be able to successfully execute all tests.
32
33 Running the tests
34 -----------------
35
36 The advised way of running tests is by using tox:
37
38 $ tox
39
40 By default, this will run the unit test suite with Python 2.7 and PEP8/HACKING
41 style checks. To run only one type of test you can explicitly invoke tox
42 with the test environment to use.
43
44 $ tox -epy27 # test suite on python 2.7
45 $ tox -epep8 # run full source code checker
46
47 To run only a subset of tests, you can provide tox with a regex argument
48 defining which tests to execute.
49
50 $ tox -epy27 -- FooTests
51
52 To use a debugger like pdb during the test run, one has to run tests directly
53 with another, non-concurrent test runner instead of using testr.
54
55 That also presumes you have a virtual env with all conductor dependencies active.
56 Below is an example bash script using the testtools test runner that also allows
57 running single tests by providing a regex.
58
59 #!/usr/bin/env sh
60 testlist=$(mktemp)
61 testr list-tests "$1" > $testlist
62 python -m testtools.run --load-list $testlist
63
64 Another way to use debugger for testing is run tox with command:
65 $ tox -e debug -- conductor.tests.test_foo.FooTest.test_foo_does_something
66
67 Note: This last approach is mostly useful to run single tests.