Execute configured groups of TestCases (subclasses of unittest.TestCase), display human readable result in terminal, ordered by group and testcase, and generate a html file report.
$ pip install testcases_executorThis also install Jinja2 used to generate html report.
Create a file named testcases.py in the root directory of your project.
Inside it, import yours TestCases and make a list (or tuple) named groups that is made up of tuples, each representing a group. For example:
from your_app.test_script import TCaseOne, TCaseTwo, TCaseThree, TCaseFour
groups = [ # or (
('Group one', 'one', [TCaseThree, TCaseTwo]), # or (TCaseThree, TCaseTwo)),
('Group two', 'two', [TCaseOne, TCaseFour]), # or (TCaseOne, TCaseFour)),
] # or )-
groups must be a list or a tuple.
-
groups's item (group's representation) must be a tuple.
-
each tuple must contain 3 items:
- group's name must be a string.
- argument's name used to run all group's testcases string without space.
- unittest.TestCase subclasses must be a list or a tuple.
-
group and argument names, unittest.TestCase subclass must used once.
$ python -m testcases_executorThis run all tests, display result in terminal before generate, in the root directory, the html report file named tc_executor_report.html. It's possible to customize the command with following availabe arguments.
-
Options
- -h, --help: display help message.
- -o, --open: open html report in browser after test.
-
Tests selection
- -group_argument_name: run all group's testcases's tests.
- -TestCaseName:(without parameter) run all testcase's tests.
- -TestCaseName:(with test's names in parameter) run desired tests.
Some examples:
$ python -m testcases_executor -two
$ python -m testcases_executor -one -TCaseFour -o
$ python -m testcases_executor -TCaseTwo test_one -TCaseOne test_three
...It use Bootstrap4, jQuery and Fontawesome icons (via stackpath cdn).
Click on table's lines to see tests's infos.
For the same reasons that meeting your future self would cause a spacio temporal shock, testing a tester using this same tester would cause a spacio testorial shock. So above all, don't.
Run testcases_executor.tests, using unittest:
$ python -m unittest testcases_executor.tests -v👍 HtmlTestRunner was a great inspiration, so thank you for that.





