Пример #1
0
        public TRXReport(TestReportCollection report, IGuidSequenceGenerator guidSequenceGenerator, TestSettings testSettings)
        {
            if (report == null)
                throw new ArgumentNullException("report");

            _report = report;
            _guidSequenceGenerator = guidSequenceGenerator;
            _testSettings = testSettings;
        }
Пример #2
0
        public void Should_spit_out_valid_MSTest_trx()
        {
            var report = new TestReportCollection();
            var testReport = new TestReport(@"C:\Test.xap");
            testReport.AddResult(TestCaseResultFactory.CreatePassed());
            testReport.AddResult(TestCaseResultFactory.CreateFailed());
            //testReport.AddResult(TestCaseResultFactory.CreateIgnored());
            report.Add(testReport);

            report
                .AllTests()
                .Where(w => w.ResultType == ResultType.Failed)
                .Each(x => x.ExceptionInfo.StackTrace = "Some message that will be a stacktrace");

            var testSettings = new TestSettings();
            testSettings.ComputerName = "UserName-LT3";
            var trxReport = new TRXReport(report, new MockGuidSequenceGenerator(), testSettings);
            var output = trxReport.GetXmlReport();

            var memoryStream = new MemoryStream();
            using (var writer = new StreamWriter(memoryStream))
            {
                var xml = output;
                xml.Save(writer);
                writer.Close();
            }

            string fileData = memoryStream.ToArray().ToStringFromByteArray();
            string expectedFileData = Resources.SampleTRX_GeneratedFromRealTest;

            FixupRegEx("duration=\"00:00:00.0000000\"", ref expectedFileData, ref fileData,
                @"duration=\""[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9]\""");

            FixupRegEx("startTime=\"0000-00-00T00:00:00.0000000-00:00\"", ref expectedFileData, ref fileData,
                @"startTime=\""[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9]:[0-9][0-9]\""");

            FixupRegEx("endTime=\"0000-00-00T00:00:00.0000000-00:00\"", ref expectedFileData, ref fileData,
                @"endTime=\""[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9]:[0-9][0-9]\""");

            //fileData.Trace();
            //expectedFileData.Trace();
            fileData.ShouldEqual(expectedFileData);
        }
Пример #3
0
        public TRXReport(TestReportCollection report, IGuidSequenceGenerator guidSequenceGenerator, TestSettings testSettings)
        {
            if (report == null)
            {
                throw new ArgumentNullException("report");
            }

            _report = report;
            _guidSequenceGenerator = guidSequenceGenerator;
            _testSettings          = testSettings;
        }