protected override void Before_all_tests() { base.Before_all_tests(); Func<ResultType, ExceptionInfo, TestCaseResultServerEvent> getResult = (resultType, exceptionInfo) => { return new TestCaseResultServerEvent(resultType) { ClassName = "class_name", MethodName = "method_name", NamespaceName = "namespace.here", Finished = new DateTime(2009, 2, 2, 2, 2, 2), Started = new DateTime(2009, 2, 2, 2, 2, 1), ExceptionInfo = exceptionInfo, XapFilePath = "Test.xap", }; }; var testReport = new TestReport("Test.xap") .AddResult(getResult(ResultType.Passed, null)) .AddResult(getResult(ResultType.Failed, new ExceptionInfo(GetException()))) .AddResult(getResult(ResultType.Ignored, null)) .AddResult(getResult(ResultType.SystemGeneratedFailure, new ExceptionInfo(new Exception("fail")))) ; _xmlReport = new XmlReport(testReport.ToTestReportCollection()); }
private static void WriteXmlReport(TestReportCollection testReports, string xmlReportOutputPath, ReportOutputFileType reportOutputFileType) { if (!string.IsNullOrEmpty(xmlReportOutputPath)) { IXmlReport xmlReport; switch (reportOutputFileType) { case ReportOutputFileType.MSGenericTest: xmlReport = new Reporting.Providers.TFS.TFS2010.MSGenericTestXmlReport(testReports); break; case ReportOutputFileType.StatLight: xmlReport = new Reporting.Providers.Xml.XmlReport(testReports); break; case ReportOutputFileType.NUnit: xmlReport = new Reporting.Providers.NUnit.NUnitXmlReport(testReports); break; case ReportOutputFileType.TRX: xmlReport = new TRXReport(testReports); break; default: throw new StatLightException("Unknown ReportOutputFileType chosen Name=[{0}], Value=[{1}]".FormatWith(reportOutputFileType.ToString(), (int)reportOutputFileType)); } xmlReport.WriteXmlReport(xmlReportOutputPath); "*********************************" .WrapConsoleMessageWithColor(Settings.Default.ConsoleColorInformation, true); "Wrote XML report to:{0}{1}" .FormatWith(Environment.NewLine, new FileInfo(xmlReportOutputPath).FullName) .WrapConsoleMessageWithColor(Settings.Default.ConsoleColorWarning, true); "*********************************" .WrapConsoleMessageWithColor(Settings.Default.ConsoleColorInformation, true); } }
public void Should_not_throw_any_exceptions_if_there_are_no_tests() { XmlReport xmlReport = new XmlReport(new TestReport("Test.xap").ToTestReportCollection()); xmlReport.GetXmlReport().ToString().ShouldNotBeEmpty(); }