Exemplo n.º 1
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.Trim();

            // replace the hard coded credentials with the current domain and user name
            expectedFileData = expectedFileData.Replace(@"DOMAIN\UserName", string.Format(@"{0}\{1}", Environment.UserDomainName, Environment.UserName));

            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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 private static IEnumerable <TestCaseResultServerEvent> GetTRXTests(TestReportCollection testReportCollection)
 {
     return(testReportCollection
            .AllTests()
            .Where(w => w.ResultType != ResultType.Ignored));
 }
Exemplo n.º 4
0
 private static IEnumerable<TestCaseResult> GetTRXTests(TestReportCollection testReportCollection)
 {
     return testReportCollection
         .AllTests()
         .Where(w => w.ResultType != ResultType.Ignored);
 }