test-case

test-case loads the data from a given file path in file for a specified test case.

Usage

.. test-case:: My Test Suite
   :file: my_test_data.xml
   :suite: my_tested_suite
   :case: my_case
   :classname: my_test_class
   :id: TESTCASE_1

The following options can be set:

  • id: Unique id for the test file. If not given, generated from title.

  • file: file path to test file. If relative, the location of conf.py folder is taken as base-folder.

  • suite: Name of the suite.

  • case: Name of the case.

  • classname: Name of the test class, which contains the case.

  • status: A status as string.

  • tags: A comma-separated list of strings.

  • links: A comma-separated list of IDs to other documented test_files / needs-objects.

  • collapse: If set to “TRUE”, meta data is collapsed. Can also be set to “FALSE”.

As different test-frameworks handle the values for test-name and test-classname differently, it is allowed to specify only case or classname. It depends on the loaded test-data, if this results in a unique test-case or if it selects only the first found test case. The best case is to always try to specify both values, case and classname.

test-suite creates a need of type Test-Suite and adds the following options automatically:

  • result: Result of the test case run. E.g passed or failed.

  • time: Needed time for running the test case

These options can also be used to filter for certain Test-Files.

Example

.. test-case:: Flake8 test case
   :id: TESTCASE_1
   :file: ../tests/data/pytest_data.xml
   :suite: pytest
   :classname: sphinxcontrib.test_reports.test_reports
   :case: FLAKE8
   :links: TESTSUITE_1

   A pytest test case.

.. test-case:: nose test case
   :file: ../tests/data/nose_data.xml
   :suite: nosetests
   :classname: test_empty_doc
   :id: TESTCASE_2

   A nosetest test case.
Test-Case: Flake8 test case TESTCASE_1
style: tr_skipped
file: ../tests/data/pytest_data.xml
suite: pytest
case: FLAKE8
case_name: FLAKE8
classname: sphinxcontrib.test_reports.test_reports
time: 0.000218152999878
result: skipped

A pytest test case.

Text:

/home/daniel/workspace/sphinx/sphinx-test-reports/.tox/py27-sphinx15/local/lib/python2.7/site-packages/pytest_flake8.py:106: <py._xmlgen.raw object at 0x7fd5a84a2a50>

Message:

file(s) previously passed FLAKE8 checks
Test-Case: nose test case TESTCASE_2
style: tr_passed
file: ../tests/data/nose_data.xml
suite: nosetests
case: None
case_name: test_doc_build_html
classname: test_empty_doc
time: 0.108
result: passed

A nosetest test case.