/// <summary> /// converts all data from the test results in to the Junit xml format and writes the xml file to disk. /// </summary> /// <param name="results"></param> public bool CreateXmlFromRunResults(TestSuiteRunResults results, out string error) { error = string.Empty; _testSuites = new testsuites(); testsuite uftts = new testsuite { errors = IntToString(results.NumErrors), tests = IntToString(results.NumTests), failures = IntToString(results.NumFailures), name = results.SuiteName, package = ClassName, time = DoubleToString(results.TotalRunTime.TotalSeconds) }; foreach (TestRunResults testRes in results.TestRuns) { if (testRes.TestType == TestType.LoadRunner.ToString()) { testsuite lrts = CreateXmlFromLRRunResults(testRes); _testSuites.AddTestsuite(lrts); } else { testcase ufttc = CreateXmlFromUFTRunResults(testRes); uftts.AddTestCase(ufttc); } } if (uftts.testcase.Length > 0) { _testSuites.AddTestsuite(uftts); } try { if (File.Exists(XmlName)) { File.Delete(XmlName); } using (Stream s = File.OpenWrite(XmlName)) { _serializer.Serialize(s, _testSuites); } return(File.Exists(XmlName)); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// converts all data from the test resutls in to the Junit xml format and writes the xml file to disk. /// </summary> /// <param name="results"></param> public void CreateXmlFromRunResults(TestSuiteRunResults results) { _testSuites = new testsuites(); testsuite ts = new testsuite { errors = results.NumErrors.ToString(), tests = results.NumTests.ToString(), failures = results.NumFailures.ToString(), name = results.SuiteName, package = ClassName }; foreach (TestRunResults testRes in results.TestRuns) { testcase tc; if (testRes.TestType == TestType.LoadRunner.ToString()) { tc = CreateXmlFromLRRunResults(testRes); } else { tc = CreateXmlFromUFTRunResults(testRes); } ts.AddTestCase(tc); } _testSuites.AddTestsuite(ts); if (File.Exists(XmlName)) File.Delete(XmlName); using (Stream s = File.OpenWrite(XmlName)) { _serializer.Serialize(s, _testSuites); } }
/// <summary> /// converts all data from the test results in to the Junit xml format and writes the xml file to disk. /// </summary> /// <param name="results"></param> public void CreateXmlFromRunResults(TestSuiteRunResults results) { _testSuites = new testsuites(); testsuite uftts = new testsuite { errors = results.NumErrors.ToString(), tests = results.NumTests.ToString(), failures = results.NumFailures.ToString(), name = results.SuiteName, package = ClassName }; foreach (TestRunResults testRes in results.TestRuns) { if (testRes.TestType == TestType.LoadRunner.ToString()) { testsuite lrts = CreateXmlFromLRRunResults(testRes); _testSuites.AddTestsuite(lrts); } else { testcase ufttc = CreateXmlFromUFTRunResults(testRes); uftts.AddTestCase(ufttc); } } if (uftts.testcase.Length > 0) { _testSuites.AddTestsuite(uftts); } if (File.Exists(XmlName)) { File.Delete(XmlName); } using (Stream s = File.OpenWrite(XmlName)) { _serializer.Serialize(s, _testSuites); } }
/// <summary> /// converts all data from the test results in to the Junit xml format and writes the xml file to disk. /// </summary> /// <param name="results"></param> public void CreateXmlFromRunResults(TestSuiteRunResults results) { _testSuites = new testsuites(); testsuite uftts = new testsuite { errors = results.NumErrors.ToString(), tests = results.NumTests.ToString(), failures = results.NumFailures.ToString(), name = results.SuiteName, package = ClassName }; foreach (TestRunResults testRes in results.TestRuns) { if (testRes.TestType == TestType.LoadRunner.ToString()) { testsuite lrts = CreateXmlFromLRRunResults(testRes); _testSuites.AddTestsuite(lrts); } else { //Console.WriteLine("CreateXmlFromRunResults, UFT test"); testcase ufttc = CreateXmlFromUFTRunResults(testRes); uftts.AddTestCase(ufttc); } } if (uftts.testcase.Length > 0) { //Console.WriteLine("CreateXmlFromRunResults, add test case to test suite"); _testSuites.AddTestsuite(uftts); } else { //Console.WriteLine("CreateXmlFromRunResults, no uft test case to write"); } if (File.Exists(XmlName)) { //Console.WriteLine("CreateXmlFromRunResults, file exist - delete file"); File.Delete(XmlName); } // else //{ //Console.WriteLine("CreateXmlFromRunResults, file does not exist"); // } using (Stream s = File.OpenWrite(XmlName)) { //Console.WriteLine("CreateXmlFromRunResults, write test results to xml file"); //Console.WriteLine("_testSuites: " + _testSuites.name + " tests: " + _testSuites.tests); //Console.WriteLine("_testSuites: " + _testSuites.ToString()); _serializer.Serialize(s, _testSuites); } //Console.WriteLine("CreateXmlFromRunResults, XmlName: " + XmlName); /*if (File.Exists(XmlName)) * { * Console.WriteLine("CreateXmlFromRunResults, results file was created"); * } else * { * Console.WriteLine("CreateXmlFromRunResults, results file was not created"); * }*/ }