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;
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var source = "TestTrxFile.trx.txt";
            var target = "TestTrxFile_output.trx.txt";

            var testRun = TrxReader.Read(source);

            TrxWriter.Write(target, testRun);
        }
Ejemplo n.º 3
0
        private async Task <IEnumerable <TestResult> > Run_Internal(IEnumerable <TestCase> testCollection)
        {
            HostApp?.RaiseTestRunStarted(testCollection);
            var t = tcs = new CancellationTokenSource();

            Status = $"Running tests...";
            OnPropertyChanged(nameof(Status));
            DiagnosticsInfo = "";
            OnPropertyChanged(nameof(DiagnosticsInfo));
            foreach (var item in testCollection)
            {
                tests[item.Id].Result = null;
            }
            OnPropertyChanged(nameof(TestStatus));
            OnPropertyChanged(nameof(NotRunTests));
            OnPropertyChanged(nameof(PassedTests));
            OnPropertyChanged(nameof(FailedTests));
            OnPropertyChanged(nameof(SkippedTests));
            OnPropertyChanged(nameof(Percentage));

            results = new List <TestResult>();
            if (!string.IsNullOrEmpty(Settings.ProgressLogPath))
            {
                var s = System.IO.File.OpenWrite(Settings.ProgressLogPath);
                logOutput = new System.IO.StreamWriter(s); // Settings.ProgressLogPath, true);
                logOutput.WriteLine("*************************************************");
                logOutput.WriteLine($"* Starting Test Run @ {DateTime.Now}");
                logOutput.WriteLine("*************************************************");
            }
            if (!string.IsNullOrEmpty(Settings.TrxOutputPath))
            {
                trxWriter = new TrxWriter(Settings.TrxOutputPath);
                trxWriter.InitializeReport();
            }
            DateTime start = DateTime.Now;

            Logger.Log($"STARTING TESTRUN {testCollection.Count()} Tests");
            var task = testRunner.Run(testCollection, t.Token);

            OnPropertyChanged(nameof(IsRunning));
            try
            {
                await task;
                if (t.IsCancellationRequested)
                {
                    Status = $"Test run canceled.";
                }
                else
                {
                    Status = $"Test run completed.";
                }
            }
            catch (System.Exception ex)
            {
                Status = $"Test run failed to run: {ex.Message}";
            }
            DateTime end = DateTime.Now;

            CurrentTestRunning = null;
            OnPropertyChanged(nameof(CurrentTestRunning));
            if (logOutput != null)
            {
                Log("*************************************************");
                Log(Status);
                Log(TestStatus);
                Log("*************************************************\n\n");
                logOutput.Dispose();
                logOutput = null;
            }
            if (trxWriter != null)
            {
                trxWriter.FinalizeReport();
                trxWriter = null;
            }
            DiagnosticsInfo += $"\nLast run duration: {(end - start).ToString("c")}";
            DiagnosticsInfo += $"\n{results.Where(a => a.Outcome == TestOutcome.Passed).Count()} passed - {results.Where(a => a.Outcome == TestOutcome.Failed).Count()} failed";
            if (Settings.ProgressLogPath != null)
            {
                DiagnosticsInfo += $"\nLog: {Settings.ProgressLogPath}";
            }
            if (Settings.TrxOutputPath != null)
            {
                DiagnosticsInfo += $"\nTRX Report: {Settings.TrxOutputPath}";
            }
            OnPropertyChanged(nameof(DiagnosticsInfo));
            OnPropertyChanged(nameof(IsRunning));
            OnPropertyChanged(nameof(Status));
            HostApp?.RaiseTestRunCompleted(results);
            Logger.Log($"COMPLETED TESTRUN Total:{results.Count()} Failed:{results.Where(a => a.Outcome == TestOutcome.Failed).Count()} Passed:{results.Where(a => a.Outcome == TestOutcome.Passed).Count()}  Skipped:{results.Where(a => a.Outcome == TestOutcome.Skipped).Count()}");
            if (Settings.TerminateAfterExecution)
            {
                Terminate();
            }
            return(results);
        }
Ejemplo n.º 4
0
 public void SetUp()
 {
     target = new TrxWriter();
     parser = new TrxParser();
     target.SummaryCalculator = new SummaryCalculatorImpl();
     windowsFileHelper        = Stub <IWindowsFileHelper>();
     target.WindowsFileHelper = windowsFileHelper;
     files = new List <ResultFile>()
     {
         new ResultFile()
         {
             Summary = new ResultSummary()
             {
                 Outcome             = "Passed",
                 Total               = 1,
                 Executed            = 2,
                 Passed              = 3,
                 Failed              = 4,
                 Error               = 5,
                 Timeout             = 6,
                 Aborted             = 7,
                 Inconclusive        = 8,
                 PassedButRunAborted = 9,
                 NotRunnable         = 10,
                 NotExecuted         = 20,
                 Disconnected        = 30,
                 Warning             = 40,
                 Completed           = 50,
                 InProgress          = 60,
                 Pending             = 70,
                 StartTime           = new DateTime(2001, 1, 21),
                 FinishTime          = new DateTime(2001, 1, 22),
             },
             Results = new List <TestResult>()
             {
                 new TestResult()
                 {
                     TestName = "TEST_A1", ClassName = "CLASS_A1", Duration = "DURATION_A1", Outcome = "OUTCOME_A1", TestId = Guid.NewGuid()
                 },
                 new TestResult()
                 {
                     TestName = "TEST_A2", ClassName = "CLASS_A2", Duration = "DURATION_A2", Outcome = "OUTCOME_A2", TestId = Guid.NewGuid(), ErrorMessage = "ERROR_A2", StackTrace = "STACK_TRACE_A2"
                 },
                 new TestResult()
                 {
                     TestName = "TEST_A3", ClassName = "CLASS_A3", Duration = "DURATION_A3", Outcome = "OUTCOME_A3", TestId = Guid.NewGuid()
                 },
             }
         },
         new ResultFile()
         {
             Summary = new ResultSummary()
             {
                 Outcome             = "Failed",
                 Total               = 10,
                 Executed            = 20,
                 Passed              = 30,
                 Failed              = 40,
                 Error               = 50,
                 Timeout             = 60,
                 Aborted             = 70,
                 Inconclusive        = 80,
                 PassedButRunAborted = 90,
                 NotRunnable         = 100,
                 NotExecuted         = 200,
                 Disconnected        = 300,
                 Warning             = 400,
                 Completed           = 500,
                 InProgress          = 600,
                 Pending             = 700,
                 StartTime           = new DateTime(2002, 1, 21),
                 FinishTime          = new DateTime(2002, 1, 22),
             },
             Results = new List <TestResult>()
             {
                 new TestResult()
                 {
                     TestName = "TEST_B1", ClassName = "CLASS_B1", Duration = "DURATION_B1", Outcome = "OUTCOME_B1", TestId = Guid.NewGuid()
                 },
                 new TestResult()
                 {
                     TestName = "TEST_B2", ClassName = "CLASS_B2", Duration = "DURATION_B2", Outcome = "OUTCOME_B2", TestId = Guid.NewGuid(), ErrorMessage = "ERROR_B2", StackTrace = "STACK_TRACE_B2"
                 },
                 new TestResult()
                 {
                     TestName = "TEST_B3", ClassName = "CLASS_B3", Duration = "DURATION_B3", Outcome = "OUTCOME_B3", TestId = Guid.NewGuid()
                 },
             }
         },
         new ResultFile()
         {
             Summary = new ResultSummary()
             {
                 Outcome             = "Passed",
                 Total               = 100,
                 Executed            = 200,
                 Passed              = 300,
                 Failed              = 400,
                 Error               = 500,
                 Timeout             = 600,
                 Aborted             = 700,
                 Inconclusive        = 800,
                 PassedButRunAborted = 900,
                 NotRunnable         = 1000,
                 NotExecuted         = 2000,
                 Disconnected        = 3000,
                 Warning             = 4000,
                 Completed           = 5000,
                 InProgress          = 6000,
                 Pending             = 7000,
                 StartTime           = new DateTime(2003, 1, 21),
                 FinishTime          = new DateTime(2003, 1, 22),
             },
             Results = new List <TestResult>()
             {
                 new TestResult()
                 {
                     TestName = "TEST_C1", ClassName = "CLASS_C1", Duration = "DURATION_C1", Outcome = "OUTCOME_C1", TestId = Guid.NewGuid()
                 },
                 new TestResult()
                 {
                     TestName = "TEST_C2", ClassName = "CLASS_C2", Duration = "DURATION_C2", Outcome = "OUTCOME_C2", TestId = Guid.NewGuid(), ErrorMessage = "ERROR_C2", StackTrace = "STACK_TRACE_C2"
                 },
                 new TestResult()
                 {
                     TestName = "TEST_C3", ClassName = "CLASS_C3", Duration = "DURATION_C3", Outcome = "OUTCOME_C3", TestId = Guid.NewGuid()
                 },
             }
         }
     };
 }
Ejemplo n.º 5
0
 public void SetUp()
 {
     target = new TrxWriter();
     parser = new TrxParser();
     target.SummaryCalculator = new SummaryCalculatorImpl();
     windowsFileHelper = Stub<IWindowsFileHelper>();
     target.WindowsFileHelper = windowsFileHelper;
     files = new List<ResultFile>()
     {
         new ResultFile()
         {
             Summary = new ResultSummary()
             {
                 Outcome = "Passed",
                 Total = 1,
                 Executed = 2,
                 Passed = 3,
                 Failed = 4,
                 Error = 5,
                 Timeout = 6,
                 Aborted = 7,
                 Inconclusive = 8,
                 PassedButRunAborted = 9,
                 NotRunnable = 10,
                 NotExecuted = 20,
                 Disconnected = 30,
                 Warning = 40,
                 Completed = 50,
                 InProgress = 60,
                 Pending = 70,
                 StartTime = new DateTime(2001, 1, 21),
                 FinishTime = new DateTime(2001, 1, 22),
             },
             Results = new List<TestResult>()
             {
                 new TestResult() { TestName = "TEST_A1", ClassName = "CLASS_A1", Duration = "DURATION_A1", Outcome = "OUTCOME_A1", TestId = Guid.NewGuid() },
                 new TestResult() { TestName = "TEST_A2", ClassName = "CLASS_A2", Duration = "DURATION_A2", Outcome = "OUTCOME_A2", TestId = Guid.NewGuid(), ErrorMessage = "ERROR_A2", StackTrace = "STACK_TRACE_A2" },
                 new TestResult() { TestName = "TEST_A3", ClassName = "CLASS_A3", Duration = "DURATION_A3", Outcome = "OUTCOME_A3", TestId = Guid.NewGuid() },
             }
         },
         new ResultFile()
         {
             Summary = new ResultSummary()
             {
                 Outcome = "Failed",
                 Total = 10,
                 Executed = 20,
                 Passed = 30,
                 Failed = 40,
                 Error = 50,
                 Timeout = 60,
                 Aborted = 70,
                 Inconclusive = 80,
                 PassedButRunAborted = 90,
                 NotRunnable = 100,
                 NotExecuted = 200,
                 Disconnected = 300,
                 Warning = 400,
                 Completed = 500,
                 InProgress = 600,
                 Pending = 700,
                 StartTime = new DateTime(2002, 1, 21),
                 FinishTime = new DateTime(2002, 1, 22),
             },
             Results = new List<TestResult>()
             {
                 new TestResult() { TestName = "TEST_B1", ClassName = "CLASS_B1", Duration = "DURATION_B1", Outcome = "OUTCOME_B1", TestId = Guid.NewGuid() },
                 new TestResult() { TestName = "TEST_B2", ClassName = "CLASS_B2", Duration = "DURATION_B2", Outcome = "OUTCOME_B2", TestId = Guid.NewGuid(), ErrorMessage = "ERROR_B2", StackTrace = "STACK_TRACE_B2" },
                 new TestResult() { TestName = "TEST_B3", ClassName = "CLASS_B3", Duration = "DURATION_B3", Outcome = "OUTCOME_B3", TestId = Guid.NewGuid() },
             }
         },
         new ResultFile()
         {
             Summary = new ResultSummary()
             {
                 Outcome = "Passed",
                 Total = 100,
                 Executed = 200,
                 Passed = 300,
                 Failed = 400,
                 Error = 500,
                 Timeout = 600,
                 Aborted = 700,
                 Inconclusive = 800,
                 PassedButRunAborted = 900,
                 NotRunnable = 1000,
                 NotExecuted = 2000,
                 Disconnected = 3000,
                 Warning = 4000,
                 Completed = 5000,
                 InProgress = 6000,
                 Pending = 7000,
                 StartTime = new DateTime(2003, 1, 21),
                 FinishTime = new DateTime(2003, 1, 22),
             },
             Results = new List<TestResult>()
             {
                 new TestResult() { TestName = "TEST_C1", ClassName = "CLASS_C1", Duration = "DURATION_C1", Outcome = "OUTCOME_C1", TestId = Guid.NewGuid() },
                 new TestResult() { TestName = "TEST_C2", ClassName = "CLASS_C2", Duration = "DURATION_C2", Outcome = "OUTCOME_C2", TestId = Guid.NewGuid(), ErrorMessage = "ERROR_C2", StackTrace = "STACK_TRACE_C2" },
                 new TestResult() { TestName = "TEST_C3", ClassName = "CLASS_C3", Duration = "DURATION_C3", Outcome = "OUTCOME_C3", TestId = Guid.NewGuid() },
             }
         }
     };
 }