public void WriteTrx() { if (Breaker.IsBreakReceived()) { return; } IList <RunData> items = RunDataListBuilder.GetFull(); IList <ResultFile> results = Collector.Collect(items); if (results.Count == 0) { Console.WriteLine("No results where generated, nothing to merge to the output trx"); return; } using (Stream stream = TrxWriter.OpenResultFile(Args)) { // Console.WriteLine("Results File: " + Args.Root + "\\" + Args.Output); if (TrxWriter.WriteFile(results, stream) == false) { ResultCode = 3; } } }
public void WriteFile() { Stream stream = new MemoryStream(); bool haveFailedTests = target.WriteFile(files, stream); Assert.IsTrue(haveFailedTests); stream.Position = 0; ResultFile result = parser.Parse(stream); Assert.AreEqual(111, result.Summary.Total); Assert.AreEqual(222, result.Summary.Executed); Assert.AreEqual(333, result.Summary.Passed); Assert.AreEqual(444, result.Summary.Failed); Assert.AreEqual(555, result.Summary.Error); Assert.AreEqual(666, result.Summary.Timeout); Assert.AreEqual(777, result.Summary.Aborted); Assert.AreEqual(888, result.Summary.Inconclusive); Assert.AreEqual(999, result.Summary.PassedButRunAborted); Assert.AreEqual(1110, result.Summary.NotRunnable); Assert.AreEqual(2220, result.Summary.NotExecuted); Assert.AreEqual(3330, result.Summary.Disconnected); Assert.AreEqual(4440, result.Summary.Warning); Assert.AreEqual(5550, result.Summary.Completed); Assert.AreEqual(6660, result.Summary.InProgress); Assert.AreEqual(7770, result.Summary.Pending); Assert.AreEqual("Failed", result.Summary.Outcome); Assert.AreEqual(new DateTime(2001, 1, 21), result.Summary.StartTime); Assert.AreEqual(new DateTime(2003, 1, 22), result.Summary.FinishTime); Assert.IsNotNull(result.Results); Assert.AreEqual(9, result.Results.Count); TestResult item; item = result.Results[0]; Assert.AreEqual("TEST_A1", item.TestName); Assert.AreEqual("CLASS_A1", item.ClassName); Assert.AreEqual("DURATION_A1", item.Duration); Assert.AreEqual("OUTCOME_A1", item.Outcome); Assert.IsNull(item.ErrorMessage); Assert.IsNull(item.StackTrace); item = result.Results[1]; Assert.AreEqual("TEST_A2", item.TestName); Assert.AreEqual("CLASS_A2", item.ClassName); Assert.AreEqual("DURATION_A2", item.Duration); Assert.AreEqual("OUTCOME_A2", item.Outcome); Assert.AreEqual("ERROR_A2", item.ErrorMessage); Assert.AreEqual("STACK_TRACE_A2", item.StackTrace); item = result.Results[2]; Assert.AreEqual("TEST_A3", item.TestName); Assert.AreEqual("CLASS_A3", item.ClassName); Assert.AreEqual("DURATION_A3", item.Duration); Assert.AreEqual("OUTCOME_A3", item.Outcome); Assert.IsNull(item.ErrorMessage); Assert.IsNull(item.StackTrace); item = result.Results[3]; Assert.AreEqual("TEST_B1", item.TestName); Assert.AreEqual("CLASS_B1", item.ClassName); Assert.AreEqual("DURATION_B1", item.Duration); Assert.AreEqual("OUTCOME_B1", item.Outcome); Assert.IsNull(item.ErrorMessage); Assert.IsNull(item.StackTrace); item = result.Results[4]; Assert.AreEqual("TEST_B2", item.TestName); Assert.AreEqual("CLASS_B2", item.ClassName); Assert.AreEqual("DURATION_B2", item.Duration); Assert.AreEqual("OUTCOME_B2", item.Outcome); Assert.AreEqual("ERROR_B2", item.ErrorMessage); Assert.AreEqual("STACK_TRACE_B2", item.StackTrace); item = result.Results[5]; Assert.AreEqual("TEST_B3", item.TestName); Assert.AreEqual("CLASS_B3", item.ClassName); Assert.AreEqual("DURATION_B3", item.Duration); Assert.AreEqual("OUTCOME_B3", item.Outcome); Assert.IsNull(item.ErrorMessage); Assert.IsNull(item.StackTrace); item = result.Results[6]; Assert.AreEqual("TEST_C1", item.TestName); Assert.AreEqual("CLASS_C1", item.ClassName); Assert.AreEqual("DURATION_C1", item.Duration); Assert.AreEqual("OUTCOME_C1", item.Outcome); Assert.IsNull(item.ErrorMessage); Assert.IsNull(item.StackTrace); item = result.Results[7]; Assert.AreEqual("TEST_C2", item.TestName); Assert.AreEqual("CLASS_C2", item.ClassName); Assert.AreEqual("DURATION_C2", item.Duration); Assert.AreEqual("OUTCOME_C2", item.Outcome); Assert.AreEqual("ERROR_C2", item.ErrorMessage); Assert.AreEqual("STACK_TRACE_C2", item.StackTrace); item = result.Results[8]; Assert.AreEqual("TEST_C3", item.TestName); Assert.AreEqual("CLASS_C3", item.ClassName); Assert.AreEqual("DURATION_C3", item.Duration); Assert.AreEqual("OUTCOME_C3", item.Outcome); Assert.IsNull(item.ErrorMessage); Assert.IsNull(item.StackTrace); }