Test Reports

There are different test reports for different situations. All test reports are stored in UTF-8.

HTML Test Report

class htf.HTMLTestReport(filename, logo=None)

HTMLTestReport creates an html test report user interface.

Initialize an HTMLTestReport instance.

Parameters:filename (str) – the filename for the html test report.
render(data)

Generates and stores an HTML encoded TestReport.

Parameters:data (dict) – test result data

JUnit XML Test Report

class htf.JUnitXMLTestReport(filename)

JUnitXMLTestReport creates a JUnit-XML test report that can be used in Jenkins for example.

Usage:

from __future__ import absolute_import, division, print_function, unicode_literals
from htf import TestLoader, TestRunner, JUnitXMLTestReport

suite = TestLoader().loadTestsFromTestCase(Test)
result = TestRunner(title="A test", reports=JUnitXMLTestReport("test.xml"), verbosity=2).run(suite)

Initialize a JUnitXMLTestReport instance.

Parameters:filename (str) – the filename for the xml test report.
render(data)

Generates and stores a JUnit-XML TestReport.

Parameters:data (dict) – test result data

JSON Test Report

class htf.JSONTestReport(filename)

JSONTestReport creates a JSON test report.

Usage:

from __future__ import absolute_import, division, print_function, unicode_literals
from htf import TestLoader, TestRunner, JSONTestReport

suite = TestLoader().loadTestsFromTestCase(Test)
result = TestRunner(title="A test", reports=JSONTestReport("test.json"), verbosity=2).run(suite)

Initialize a JSONTestReport instance.

Parameters:filename (str) – the filename for the json test report.
render(data)

Generates and stores a JSON encoded TestReport.

Parameters:data (dict) – test result data

IBM Rational DOORS Test Report

class htf.DOORSTestReport(filename, reportModule, requirementsModules, linksModules=None, renderMetaData=True, renderSteps=True)

DOORSTestReport creates a DOORS test report. Links are automatically created from the created DOORS module to the fulfilled requirements.

To state the fulfilled requirements the meetsDOORSRequirements() decorator should be used.

Usage:

from __future__ import absolute_import, division, print_function, unicode_literals
from htf import TestLoader, TestCase, TestRunner, DOORSTestReport, meetsDOORSRequirements

class Test(TestCase):
    @meetsDOORSRequirements("REQ_1", "REQ_2", "REQ_3", "TEST_1")
    def testWithDOORSLinks(self):
        pass

suite = TestLoader().loadTestsFromTestCase(Test)

result = TestRunner(title="DOORS test report",
                    reports=[
                             DOORSTestReport(filename="doors.dxl",
                                             reportModule="/path/to/report/module",
                                             requirementsModules={
                                                 "REQ_.*" : "/path/to/requirements_module",
                                                 "TEST_.*" : "/path/to/test_specification",
                                             },
                                             linksModules={
                                                 "REQ_.*" : "/path/to/links/to/requirements_module",
                                                 "TEST_.*" : "/path/to/links/to/test_specification",
                                                 }
                                             )
                             ],
                    verbosity=2).run(suite)

Initialize a DOORSTestReport instance.

Parameters:
  • filename (str) – the filename for the DXL test report.
  • reportModule (str) – the DOORS path to the report module.
  • requirementsModules (dict) – maps links to DOORS modules. The keys are regular expressions and the values are the desired target modules.
  • linksModules={".*" – “DOORS Links”} (dict): maps requirements to desired link modules. The keys are regular expressions and the values are the desired link modules.
  • renderMetaData=True (bool) – if set to True metadata is rendered in DOORS
  • renderSteps=True (bool) – if set to True steps are rendered in DOORS
render(data)

Generates and stores a DXL encoded TestReport.

Parameters:data (dict) – test result data