Beispiel #1
0
    def test_skipped_and_failed_summary_messages(self):
        """Verify the skipped and failed messages in the summary.

        """

        sequencer = Sequencer(
            "execute_test_skipped_and_failed_summary_messages")

        result = sequencer.run(
            [SkipTest("1", 'My skip message.'),
             FailTest("1")])

        self.assert_result(result, Result(0, 1, 1))

        sequencer.report()

        json_report = sequencer.summary_json()
        self.assertEqual(json_report["testcases"][0]['name'], 'skip_1')
        self.assertEqual(json_report["testcases"][0]['result'], 'SKIPPED')
        self.assertEqual(json_report["testcases"][0]['message'],
                         'My skip message.')
        self.assertEqual(json_report["testcases"][1]['name'], 'fail_1')
        self.assertEqual(json_report["testcases"][1]['result'], 'FAILED')
        self.assertTrue(json_report["testcases"][1]['message'].endswith(
            '1 is not equal to 0'))
Beispiel #2
0
    def test_serial_parallel(self):
        """Run a sequence of serial and parallel tests.

        """

        sequencer = Sequencer("serial_parallel")

        # Run a bunch of tests.
        passed, failed, skipped = sequencer.run(
            NamedTest("a"),
            [NamedTest("b")],
            # Tests in a tuple are executed in parallel.
            (NamedTest("c", work_time=0.2), NamedTest("d"), NamedTest("e"),
             (NamedTest("f"), NamedTest("g")), NamedTest("h"),
             (NamedTest("i", work_time=0.1), NamedTest("j"), FailTest("a")),
             [FailTest("b"), [NotExecutedTest("a")]], FailTest("c")),
            [NotExecutedTest("b")],
            NamedTest("k"),
            NamedTest("l"))

        sequencer.report()

        self.assertEqual(passed, 12)
        self.assertEqual(failed, 3)
        self.assertEqual(skipped, 2)
        self.assertEqual(NamedTest.count, 12)
        self.assertEqual(NotExecutedTest.count, 0)
        self.assertEqual(FailTest.count, 3)

        json_report = sequencer.summary_json()
        print(json.dumps(json_report, indent=4))
        self.assertEqual(json_report["name"], "serial_parallel")
        self.assertEqual(len(json_report["testcases"]), 17)
Beispiel #3
0
    def test_testcase_description(self):
        """Test the testcase descriptions.

        """

        sequencer = Sequencer("testcase descriptions")

        result = sequencer.run(DescriptionNoneTest(), DescriptionEmptyTest(),
                               DescriptionBlankTest(),
                               DescriptionMultiLineTest())

        sequencer.report()

        self.assert_result(result, Result(4, 0, 0))

        json_report = sequencer.summary_json()
        self.assertEqual(json_report["testcases"][0]['description'], [])
        self.assertEqual(json_report["testcases"][1]['description'], [])
        self.assertEqual(json_report["testcases"][2]['description'], [])
        self.assertEqual(json_report["testcases"][3]['description'],
                         ['Line 1.', 'Line 2.', 'Line 3.'])