def test_set_failure_after_set(self):
     jr = junit_report_format.JunitTestReport()
     jts = jr.create_new_testsuite("testname", "testpackage")
     jtc = jts.create_new_testcase("test_success", "testcase.test.success")
     jtc.SetSuccess()
     with self.assertRaises(Exception):
         jtc.SetFailed("Testing the failure path", "TEST")
 def test_set_error_after_set(self):
     jr = junit_report_format.JunitTestReport()
     jts = jr.create_new_testsuite("testname", "testpackage")
     jtc = jts.create_new_testcase("test_failed", "testcase.test.failed")
     jtc.SetFailed("Testing the failure path", "TEST")
     with self.assertRaises(Exception):
         jtc.SetError("Bad test", "Bad Type")
 def test_incomplete_test_results(self):
     jr = junit_report_format.JunitTestReport()
     jts = jr.create_new_testsuite("testname", "testpackage")
     jtc = jts.create_new_testcase("test_failed", "testcase.test.failed")
     jtc.LogStdError("Message to standard error on failed case")
     # Don't set State jtc.SetFailed("Testing the failure path", "TEST")
     f = os.path.join(self.test_dir, "testoutput.xml")
     with self.assertRaises(Exception):
         jr.Output(f)
 def test_xml_escape_in_testsuit_name_package_output(self):
     jr = junit_report_format.JunitTestReport()
     jts = jr.create_new_testsuite("testname\"<", ">&'testpackage")
     jtc = jts.create_new_testcase("test_failed", "testcase.test.failed")
     jtc.SetSuccess()
     f = os.path.join(self.test_dir, "testoutput.xml")
     jr.Output(f)
     self.assertTrue(os.path.isfile(f))
     Valid, Msg = self.IsXmlFileValidXml(f)
     self.assertTrue(Valid, msg=Msg)
 def test_xml_escape_in_error_type(self):
     jr = junit_report_format.JunitTestReport()
     jts = jr.create_new_testsuite("testname", "testpackage")
     jtc = jts.create_new_testcase("test_error", "testcase.test.error")
     jtc.SetError("Message in Error case", 'Error&')
     f = os.path.join(self.test_dir, "testoutput.xml")
     jr.Output(f)
     self.assertTrue(os.path.isfile(f))
     Valid, Msg = self.IsXmlFileValidXml(f)
     self.assertTrue(Valid, msg=Msg)
 def test_xml_escape_in_failed_type(self):
     jr = junit_report_format.JunitTestReport()
     jts = jr.create_new_testsuite("testname", "testpackage")
     jtc = jts.create_new_testcase("test_failed", "testcase.test.failed")
     jtc.SetFailed("Message in failed case", "'Fa>ile\"d<")
     f = os.path.join(self.test_dir, "testoutput.xml")
     jr.Output(f)
     self.assertTrue(os.path.isfile(f))
     Valid, Msg = self.IsXmlFileValidXml(f)
     self.assertTrue(Valid, msg=Msg)
 def test_xml_escape_in_std_error_output(self):
     jr = junit_report_format.JunitTestReport()
     jts = jr.create_new_testsuite("testname", "testpackage")
     jtc = jts.create_new_testcase("test_failed", "testcase.test.failed")
     jtc.LogStdError("Message to standard error on failed case with < char")
     jtc.SetSuccess()
     f = os.path.join(self.test_dir, "testoutput.xml")
     jr.Output(f)
     self.assertTrue(os.path.isfile(f))
     Valid, Msg = self.IsXmlFileValidXml(f)
     self.assertTrue(Valid, msg=Msg)
 def test_valid(self):
     jr = junit_report_format.JunitTestReport()
     jts = jr.create_new_testsuite("testname", "testpackage")
     jtc = jts.create_new_testcase("test_failed", "testcase.test.failed")
     jtc.LogStdError("Message to standard error on failed case")
     jtc.SetFailed("Testing the failure path", "TEST")
     jtc2 = jts.create_new_testcase("test_success", "testcase.test.success")
     jtc2.LogStdOut("Message to standard out on success case")
     jtc2.SetSuccess()
     jtc3 = jts.create_new_testcase("test_skipped", "testcase.test.skipped")
     jtc3.SetSkipped()
     jtc4 = jts.create_new_testcase("test_error", "testcase.test.error")
     jtc4.SetError("Testing the error path", "exception")
     f = os.path.join(self.test_dir, "testoutput.xml")
     jr.Output(f)
     self.assertTrue(os.path.isfile(f))