Exemple #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()))
Exemple #2
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))
Exemple #3
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))
Exemple #4
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"))
Exemple #5
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"))
Exemple #6
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))
Exemple #7
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))
Exemple #8
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
Exemple #9
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))
Exemple #10
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))
Exemple #11
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