Exemple #1
0
            public override void Handle(TestRunnerAgent agent)
            {
                if (agent.state != null || testModules.Count < 1)
                {
                    return;
                }

                agent.state               = new RunningState(testModules);
                agent.target.Duration     = TimeSpan.Zero;
                agent.target.PassedCount  = 0;
                agent.target.FailedCount  = 0;
                agent.target.SkippedCount = 0;

                foreach (var testModule in testModules)
                {
                    foreach (var testCase in testModule.TestCaseMap.Values)
                    {
                        testCase.Status = TestCaseStatus.NotRun;
                    }

                    Task.Run(() => agent.StartRun(testModule), agent.state.Cancellation.Token);
                }

                agent.target.IsRunningTests = true;
            }
Exemple #2
0
            public override void Handle(TestRunnerAgent agent)
            {
                if (agent.state == null)
                {
                    return;
                }

                agent.state.Cancellation.Cancel();
                agent.StopRun();
            }
Exemple #3
0
            public override void Handle(TestRunnerAgent agent)
            {
                if (agent.state == null)
                {
                    return;
                }

                agent.state.TestModules.Remove(testModule);

                if (agent.state.TestModules.Count < 1)
                {
                    agent.StopRun();
                }
            }
Exemple #4
0
 public TestEventListener(TestRunnerAgent agent, TestModule testModule)
 {
     this.agent      = agent;
     this.testModule = testModule;
 }
Exemple #5
0
            public override void Handle(TestRunnerAgent agent)
            {
                if (agent.state != null)
                {
                    agent.target.Duration = DateTime.Now - agent.state.StartTime;
                }

                var node = XmlHelper.CreateXmlNode(report);

                var testName = node.Attributes?.GetNamedItem("fullname")?.Value;

                if (string.IsNullOrWhiteSpace(testName))
                {
                    return;
                }

                TestCase testCase;

                if (!testModule.TestCaseMap.TryGetValue(testName, out testCase))
                {
                    return;
                }

                var increaseCounter = 0;

                switch (node.Name)
                {
                case "start-suite":
                case "start-test":
                    testCase.Status = TestCaseStatus.Running;
                    return;

                case "test-case":
                    increaseCounter = 1;
                    break;

                case "test-suite":
                    break;

                default:
                    return;
                }

                var result = node.Attributes.GetNamedItem("result").Value;

                TestState.
                switch (result)
                {
                case "Skipped":
                    testCase.Status            = TestCaseStatus.Skipped;
                    testCase.Message           = node.SelectSingleNode("./reason/message")?.InnerText ?? "";
                    agent.target.SkippedCount += increaseCounter;
                    break;

                case "Passed":
                    testCase.Status           = TestCaseStatus.Passed;
                    agent.target.PassedCount += increaseCounter;
                    break;

                case "Failed":
                    testCase.Status           = TestCaseStatus.Failed;
                    testCase.Message          = node.SelectSingleNode("./failure/message")?.InnerText ?? "";
                    agent.target.FailedCount += increaseCounter;
                    break;

                default:
                    throw new Exception($"Unhandled test result: {result}.");
                }
            }
Exemple #6
0
 public abstract void Handle(TestRunnerAgent agent);