def test_should_create_testsuite_tag_if_only_one_testsuite_registered(self): suite = suite_mock() result = Xunit(suite) xml = result.to_xml() suite.to_xml.assert_called_once() assert_that(xml, is_(suite.to_xml()))
def test_should_create_testsuites_root_tag_if_more_than_one_testsuite_registered(self): result = Xunit() result.append(suite_mock()) result.append(suite_mock()) xml = result.to_xml() assert_that(xml.tag, is_("testsuites")) assert_that([child for child in xml], has_length(2))
def test_should_aggregate_all_suite_names(self): suite = XunitSuite("name") suite2 = XunitSuite("other name") results = Xunit() results.append(suite) results.append(suite2) names = [x.name for x in results.suites] assert_that(names, has_item("name")) assert_that(names, has_item("other name"))
def test_should_create_xml_that_is_valid_according_to_the_JUnit_jenkins_schema(self): test = XunitTest("test1") suite = XunitSuite("suite1") suite.append(test) result = Xunit() result.append(suite) try: xml = etree.fromstring(result.to_string(), PARSER) except etree.XMLSyntaxError as err: print(str(err)) self.fail("Should have parsed without errors") else: pass
def test_should_aggregate_test_counts_from_all_suites(self): suite = XunitSuite("name") test_mock = Mock(XunitTest) suite.append(test_mock) suite.append(test_mock) results = Xunit() results.append(suite) assert_that(results.total_test_count, is_(2)) results.append(suite) assert_that(results.total_test_count, is_(4)) suite.append(test_mock) assert_that(results.total_test_count, is_(6))
def from_yaml(yaml_input): """Parse provided yaml and instantiate an Xunit object from that""" report_description = yaml.load(yaml_input) report = Xunit() for test_suite, data in report_description.items(): suite = XunitSuite(test_suite) report.append(suite) if data is None: continue for test, test_data in data.items(): test_result = XunitTest(test, test_suite) if test_data and 'status' in test_data: test_result.status = test_data['status'] suite.append(test_result) return report
def test_should_force_package_inclusion_when_converting_multiple_suites_to_xml(self): result = Xunit() suite = suite_mock() result.append(suite) result.append(suite_mock()) xml = result.to_xml() suite.to_xml.assert_called_once_with(force_package=True, id=0)
def test_should_give_each_suite_an_id_when_converting_multiple_suites_to_xml(self): result = Xunit() suite = suite_mock() suite2 = suite_mock() result.append(suite) result.append(suite2) xml = result.to_xml() suite.to_xml.assert_called_once_with(force_package=True, id=0) suite2.to_xml.assert_called_once_with(force_package=True, id=1)
def test_should_stringify_into_proper_xml_document(self): result = Xunit() xml = result.to_string() assert_that(xml, contains_string('<?xml version="1.0" encoding="UTF-8"?>'))