public Report ProcessFile() { // create a data instance to be passed to the folder level report _report = new Report { FileName = this._testResultFile, RunInfo = {TestRunner = TestRunner.NUnit}, Total = _doc.GetElementsByTagName("test-case").Count, AssemblyName = _doc.SelectNodes("//test-suite")[0].Attributes["name"].InnerText }; // get total count of tests from the input file Console.WriteLine("[INFO] Number of tests: " + _report.Total); // only proceed if the test count is more than 0 if (_report.Total >= 1) { Console.WriteLine("[INFO] Processing root and test-suite elements..."); // pull values from XML source _report.Passed = _doc.SelectNodes(".//test-case[@result='Success' or @result='Passed']").Count; _report.Failed = _doc.SelectNodes(".//test-case[@result='Failed' or @result='Failure']").Count; _report.Inconclusive = _doc.SelectNodes(".//test-case[@result='Inconclusive' or @result='NotRunnable']").Count; _report.Skipped = _doc.SelectNodes(".//test-case[@result='Skipped' or @result='Ignored']").Count; _report.Errors = _doc.SelectNodes(".//test-case[@result='Error']").Count; _report.Status = _doc.SelectNodes("//test-suite")[0].Attributes["result"].InnerText.AsStatus(); try { double duration; if (double.TryParse(_doc.SelectNodes("//test-suite")[0].Attributes["duration"].InnerText, out duration)) { _report.Duration = duration; } } catch { try { double duration; if (double.TryParse(_doc.SelectNodes("//test-suite")[0].Attributes["time"].InnerText, out duration)) { _report.Duration = duration; } } catch { } } ProcessRunInfo(); ProcessFixtureBlocks(); } else { _report.Status = Status.Passed; } return _report; }
public Report ProcessFile() { // create a data instance to be passed to the folder level report _report = new Report(); _report.FileName = this._testResultFile; _report.RunInfo.TestRunner = TestRunner.NUnit; // get total count of tests from the input file _report.Total = _doc.GetElementsByTagName("test-case").Count; _report.AssemblyName = _doc.SelectNodes("//test-suite")[0].Attributes["name"].InnerText; _assemblyNameWithoutExtension = Path.GetFileNameWithoutExtension(_report.AssemblyName); logger.Info("Number of tests: " + _report.Total); // only proceed if the test count is more than 0 if (_report.Total >= 1) { logger.Info("Processing root and test-suite elements..."); // pull values from XML source _report.Passed = _doc.SelectNodes(".//test-case[@result='Success' or @result='Passed']").Count; _report.Failed = _doc.SelectNodes(".//test-case[@result='Failed' or @result='Failure']").Count; _report.Inconclusive = _doc.SelectNodes(".//test-case[@result='Inconclusive' or @result='NotRunnable']").Count; _report.Skipped = _doc.SelectNodes(".//test-case[@result='Skipped' or @result='Ignored']").Count; _report.Errors = _doc.SelectNodes(".//test-case[@result='Error']").Count; try { double duration; if (double.TryParse(_doc.SelectNodes("//test-suite")[0].Attributes["duration"].InnerText, out duration)) { _report.Duration = duration; } } catch { try { double duration; if (double.TryParse(_doc.SelectNodes("//test-suite")[0].Attributes["time"].InnerText, out duration)) { _report.Duration = duration; } } catch { } } ProcessRunInfo(); ProcessFixtureBlocks(); _report.Status = ReportHelper.GetFixtureStatus(_report.TestFixtures.SelectMany(x => x.Tests)); } else { _report.Status = Status.Passed; } return _report; }
public Report ProcessFile() { // create a data instance to be passed to the folder level report _report = new Report(); _report.FileName = this._testResultFile; _report.RunInfo.TestRunner = TestRunner.MSTest2010; // get total count of tests from the input file _report.Total = _doc.SelectNodes("descendant::t:UnitTestResult", _nsmgr).Count; Console.WriteLine("[INFO] Number of tests: " + _report.Total); // only proceed if the test count is more than 0 if (_report.Total >= 1) { Console.WriteLine("[INFO] Processing root and test-suite elements..."); // pull values from XML source _report.AssemblyName = _doc.GetElementsByTagName("UnitTest")[0]["TestMethod"].Attributes["codeBase"].InnerText; _report.Passed = _doc.SelectNodes("descendant::t:UnitTestResult[@outcome='Passed']", _nsmgr).Count; _report.Failed = _doc.SelectNodes("descendant::t:UnitTestResult[@outcome='Failed']", _nsmgr).Count; _report.Inconclusive = _doc.SelectNodes("descendant::t:UnitTestResult[@outcome='Inconclusive' or @outcome='notRunnable' or @outcome='passedButRunAborted' or @outcome='disconnected' or @outcome='warning' or @outcome='pending']", _nsmgr).Count; _report.Skipped = _doc.SelectNodes("descendant::t:UnitTestResult[@outcome='NotExecuted']", _nsmgr).Count; _report.Errors = _doc.SelectNodes("descendant::t:UnitTestResult[@outcome='Error' or @outcome='Aborted' or @outcome='timeout']", _nsmgr).Count; try { XmlNode times = _doc.SelectSingleNode("descendant::t:Times", _nsmgr); if (times != null) _report.Duration = DateTimeHelper.DifferenceInMilliseconds(times.Attributes["start"].InnerText, times.Attributes["finish"].InnerText); } catch { } ProcessRunInfo(); ProcessFixtureBlocks(); _report.Status = ReportHelper.GetFixtureStatus(_report.TestFixtures.SelectMany(tf => tf.Tests).ToList()); } else { try { _report.Status = Status.Passed; return _report; } catch (Exception ex) { Console.WriteLine("Something weird happened: " + ex.Message); return null; } } return _report; }
public Report ProcessFile() { _fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this._testResultFile); _assemblyFilePath = (_doc.SelectNodes("//assembly") != null && _doc.SelectNodes("//assembly").Count > 0) ? _doc.SelectNodes("//assembly")[0].Attributes["name"].InnerText : _testResultFile; _assemblyFolder = _assemblyFilePath.Replace(Path.GetFileName(_assemblyFilePath), ""); // create a data instance to be passed to the folder level report _report = new Report(); _report.FileName = this._testResultFile; _report.RunInfo.TestRunner = TestRunner.XUnitV1; // get total count of tests from the input file _report.Total = _doc.GetElementsByTagName("test").Count; _report.AssemblyName = Path.GetFileName(_assemblyFilePath); Console.WriteLine("[INFO] Number of tests: " + _report.Total); // only proceed if the test count is more than 0 if (_report.Total >= 1) { Console.WriteLine("[INFO] Processing root and collection elements..."); // pull values from XML source _report.Passed = _doc.SelectNodes(".//test[@result='Success' or @result='Passed' or @result='Pass']").Count; _report.Failed = _doc.SelectNodes(".//test[@result='Fail' or @result='Failed' or @result='Failure']").Count; _report.Inconclusive = _doc.SelectNodes(".//test[@result='Inconclusive' or @result='NotRunnable']").Count; _report.Skipped = _doc.SelectNodes(".//test[@result='Skipped' or @result='Ignored']").Count; _report.Errors = _doc.SelectNodes(".//test[@result='Error' or @result='Errored']").Count; try { double duration; if (double.TryParse(_doc.SelectNodes("//assembly")[0].Attributes["time"].InnerText, out duration)) { _report.Duration = duration; } } catch { } ProcessRunInfo(); ProcessFixtureBlocks(); _report.Status = ReportHelper.GetFixtureStatus(_report.TestFixtures.SelectMany(x => x.Tests)); } else { _report.Status = Status.Passed; } return _report; }
public Report ProcessFile() { // create a data instance to be passed to the folder level report _report = new Report(); _report.FileName = this._testResultFile; _report.RunInfo.TestRunner = TestRunner.Gallio; // get total count of tests from the input file _report.Total = _doc.SelectNodes("descendant::ns:testStep[@isTestCase='true']", _nsmgr).Count; _report.AssemblyName = _doc.SelectSingleNode("//ns:files/ns:file", _nsmgr).InnerText; Console.WriteLine("[INFO] Number of tests: " + _report.Total); if (_report.Total >= 1) { Console.WriteLine("[INFO] Processing root and test-suite elements..."); // pull values from XML source _report.Passed = Int32.Parse(_doc.SelectSingleNode("//ns:statistics/@passedCount", _nsmgr).InnerText); _report.Failed = Int32.Parse(_doc.SelectSingleNode("//ns:statistics/@failedCount", _nsmgr).InnerText); _report.Inconclusive = Int32.Parse(_doc.SelectSingleNode("//ns:statistics/@inconclusiveCount", _nsmgr).InnerText); _report.Skipped = Int32.Parse(_doc.SelectSingleNode("//ns:statistics/@skippedCount", _nsmgr).InnerText); _report.Errors = 0; XmlNode testPackageRun = _doc.SelectSingleNode("descendant::ns:testPackageRun", _nsmgr); if (testPackageRun != null) { _report.Duration = DateTimeHelper.DifferenceInMilliseconds(testPackageRun.Attributes["startTime"].InnerText, testPackageRun.Attributes["endTime"].InnerText); } ProcessRunInfo(); ProcessFixtureBlocks(); _report.Status = _doc.SelectNodes("descendant::ns:testPackageRun/ns:testStepRun/ns:result/ns:outcome/@status", _nsmgr)[0].InnerText.AsStatus(); } else { _report.Status = Status.Passed; } return _report; }