Ejemplo n.º 1
0
 def test_should_append_tests_to_xml_output(self):
     suite = XunitSuite("my_name")
     test = test_mock()
     suite.append(test)                
     
     xml = suite.to_xml()
     assert_that(xml[0], is_(test.to_xml()))
Ejemplo n.º 2
0
    def test_should_report_id_in_xml_tag_if_one_is_provided(self):
        suite = XunitSuite("my_name")
        result = suite.to_xml(id=2)
        assert_that(result.attrib['id'], is_("2"))

        result = suite.to_xml(id=8)
        assert_that(result.attrib['id'], is_("8"))
Ejemplo n.º 3
0
 def test_should_report_name_in_xml_tag_as_name_attribute(self):
     suite = XunitSuite("my_name")
     result = suite.to_xml()
     assert_that(result.attrib['name'], is_("my_name"))
     
     suite = XunitSuite("different_suite")
     result = suite.to_xml()
     assert_that(result.attrib['name'], is_("different_suite"))
Ejemplo n.º 4
0
 def test_should_report_package_in_xml_tag_as_package_attribute_if_present(self):
     suite = XunitSuite("my_name")
     result = suite.to_xml()
     assert_that('package' in result.attrib, is_(False), "shouldn't have package attribute")
     
     suite = XunitSuite("my_name", package="Pack1")
     result = suite.to_xml()
     assert_that(result.attrib['package'], is_("Pack1"))
Ejemplo n.º 5
0
    def test_should_maintain_count_of_passing_tests(self):
        suite = XunitSuite("testsuite")
        test1 = Mock(XunitTest)

        assert_that(suite.number_passing, is_(0))
        suite.append(test1)
        assert_that(suite.number_passing, is_(1))
        suite.append(test1)
        assert_that(suite.number_passing, is_(2))
Ejemplo n.º 6
0
    def test_should_aggregate_test_results(self):
        suite = XunitSuite("testsuite")
        test1 = Mock(XunitTest)

        assert_that(suite.test_count, is_(0))
        suite.append(test1)
        assert_that(suite.test_count, is_(1))
        suite.append(test1)
        assert_that(suite.test_count, is_(2))
Ejemplo n.º 7
0
    def test_should_report_total_time_in_xml_tag_as_time_attribute(self):
        test = test_mock()
        suite = XunitSuite("my_name")
        result = suite.to_xml()

        assert_that(result.attrib['time'], is_("0.0"))

        suite.append(test)
        result = suite.to_xml()
        assert_that(result.attrib['time'], is_("1.5"))
Ejemplo n.º 8
0
    def test_should_report_skip_count_in_xml_tag_as_skipped_attribute(self):
        test = test_mock("skipped")
        suite = XunitSuite("my_name")
        result = suite.to_xml()
        
        assert_that(result.attrib['skipped'], is_("0"))

        suite.append(test)
        result = suite.to_xml()
        assert_that(result.attrib['skipped'], is_("1"))
Ejemplo n.º 9
0
    def test_should_maintain_count_of_tests_that_were_skipped(self):
        suite = XunitSuite("skip_suite")
        test1 = Mock(XunitTest)
        test1.passed = False
        test1.status = "skipped"

        assert_that(suite.skipped_count, is_(0))
        
        suite.append(test1)
        assert_that(suite.skipped_count, is_(1))
Ejemplo n.º 10
0
    def test_should_aggregate_run_time_of_tests(self):
        suite = XunitSuite("testsuite")
        test1 = XunitTest("test", time=0.5)

        assert_that(suite.total_time, is_(0.0))
        
        suite.append(test1)
        assert_that(suite.total_time, is_(0.5))
 
        suite.append(test1)
        assert_that(suite.total_time, is_(1.0))
Ejemplo n.º 11
0
    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
Ejemplo n.º 12
0
    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))
Ejemplo n.º 13
0
    def test_should_maintain_count_of_tests_that_had_errors(self):
        suite = XunitSuite("errorsuite")
        test1 = Mock(XunitTest)
        test1.passed = False
        test1.status = "error"
        assert_that(suite.error_count, is_(0))
        
        suite.append(test1)
        assert_that(suite.error_count, is_(1))
        
        test2 = Mock(XunitTest)
        test2.passed = False
        test2.status = "failed"
 
        suite.append(test2)
        assert_that(suite.error_count, is_(1))
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
 def test_should_report_empty_package_if_none_was_provided_and_force_package_is_used(self):
     suite = XunitSuite("my_name")
     result = suite.to_xml(force_package=True)
     assert_that(result.attrib['package'], is_(""))
Ejemplo n.º 16
0
    def test_should_create_testsuite_node_as_xml_output(self):
        suite = XunitSuite("testsuite")
        result = suite.to_xml()

        assert_that(result.tag, is_("testsuite"))