Exemplo n.º 1
0
        public void OnTestEvent(string report)
        {
            var xmlNode = XmlHelper.CreateXmlNode(report);

            switch (xmlNode.Name)
            {
            case "start-run":
            {
                Reporter.RunStarted();
                break;
            }

            case "test-run":
            {
                Reporter.RunFinished();
                break;
            }

            case "start-test":
            {
                Reporter.TestStarted(TestRunHelper.GetTestRunOnStarted(xmlNode));
                break;
            }

            case "test-case":
            {
                Reporter.TestFinished(TestRunHelper.GetTestRunOnFinished(xmlNode));
                break;
            }
            }
        }
Exemplo n.º 2
0
 public void BeforeTest(ITest nunitTest)
 {
     if (!Reporter.TestRunStarted)
     {
         Reporter.RunStarted();
     }
     if (!nunitTest.IsSuite)
     {
         var ghprTest = TestRunHelper.GetTestRunOnStarted(GetTestNode(nunitTest));
         Reporter.TestFinished(ghprTest);
     }
 }
Exemplo n.º 3
0
 public void BeforeTest(ITest nunitTest)
 {
     if (!Reporter.TestRunStarted)
     {
         Reporter.RunStarted();
     }
     if (!nunitTest.IsSuite)
     {
         var ghprTest = TestRunHelper.GetTestRunOnStarted(GetTestNode(nunitTest), DateTime.UtcNow, Reporter.Logger);
         Reporter.TestFinished(ghprTest.GhprTestRun, ghprTest.GhprTestOutput);
     }
 }
        public void OnTestEvent(string report)
        {
            var eventTime = DateTime.UtcNow;
            var xmlNode   = XmlHelper.CreateXmlNode(report);

            switch (xmlNode.Name)
            {
            case "start-run":
            {
                var cmd      = Environment.CommandLine;
                var args     = Environment.GetCommandLineArgs();
                var projName = args.Length >= 2 ? args[1] : cmd;
                Reporter = ReporterFactory.Build(TestingFramework.NUnit, new TestDataProvider(), projName);
                Reporter.RunStarted();
                _testCases  = new List <GhprTestCase>();
                _testSuites = new List <GhprTestSuite>();
                break;
            }

            case "start-test":
            {
                var testRun = TestRunHelper.GetTestRunOnStarted(xmlNode, eventTime, Reporter.Logger);
                Reporter.TestStarted(testRun.GhprTestRun);
                break;
            }

            case "test-case":
            {
                var testCase = TestRunHelper.GetTestRunOnFinished(xmlNode, eventTime, Reporter.Logger);
                testCase.GhprTestOutput.TestOutputInfo.Date = eventTime;
                foreach (var screenshot in testCase.GhprTestScreenshots)
                {
                    var testScreenshotInfo = Reporter.DataWriterService.SaveScreenshot(screenshot);
                    if (testCase.GhprTestRun.Screenshots.All(s => s.Date != screenshot.TestScreenshotInfo.Date))
                    {
                        testCase.GhprTestRun.Screenshots.Add(testScreenshotInfo);
                    }
                }
                Reporter.TestFinished(testCase.GhprTestRun, testCase.GhprTestOutput);
                _testCases.Add(testCase);
                break;
            }

            case "test-suite":
            {
                var testSuite = TestRunHelper.GetTestSuite(xmlNode);
                _testSuites.Add(testSuite);
                var tests = _testCases.Where(tc => tc.ParentId.Equals(testSuite.Id) && !tc.ParentId.Equals(""))
                            .ToList();
                var childSuites = _testSuites
                                  .Where(ts => ts.ParentId.Equals(testSuite.Id) && !ts.ParentId.Equals("") && ts.Type.Equals("ParameterizedFixture")).ToList();
                foreach (var suite in childSuites)
                {
                    tests.AddRange(_testCases.Where(tc => tc.ParentId.Equals(suite.Id) && !tc.ParentId.Equals("")));
                }
                foreach (var test in tests)
                {
                    test.GhprTestOutput.SuiteOutput = testSuite.Output;
                    Reporter.DataWriterService.UpdateTestOutput(test.GhprTestRun.TestInfo, test.GhprTestOutput);
                }

                break;
            }

            case "test-run":
            {
                Reporter.RunFinished();
                Reporter.CleanUpJob();
                Reporter.TearDown();
                break;
            }
            }
        }
Exemplo n.º 5
0
        public void OnTestEvent(string report)
        {
            var eventTime = DateTime.Now;
            var xmlNode   = XmlHelper.CreateXmlNode(report);

            switch (xmlNode.Name)
            {
            case "start-run":
            {
                Reporter.RunStarted();
                _testCases  = new List <GhprTestCase>();
                _testSuites = new List <GhprTestSuite>();
                break;
            }

            case "start-test":
            {
                var testRun = TestRunHelper.GetTestRunOnStarted(xmlNode, eventTime, Reporter.Logger);
                Reporter.TestStarted(testRun.GhprTestRun);
                break;
            }

            case "test-case":
            {
                var testCase = TestRunHelper.GetTestRunOnFinished(xmlNode, eventTime, Reporter.Logger);
                testCase.GhprTestOutput.TestOutputInfo.Date = eventTime;
                foreach (var screenshot in testCase.GhprTestScreenshots)
                {
                    var testScreenshotInfo = Reporter.DataWriterService.SaveScreenshot(screenshot);
                    testCase.GhprTestRun.Screenshots.Add(testScreenshotInfo);
                }
                Reporter.TestFinished(testCase.GhprTestRun, testCase.GhprTestOutput);
                _testCases.Add(testCase);
                break;
            }

            case "test-suite":
            {
                var testSuite = TestRunHelper.GetTestSuite(xmlNode);
                _testSuites.Add(testSuite);
                var tests = _testCases.Where(tc => tc.ParentId.Equals(testSuite.Id) && !tc.ParentId.Equals(""))
                            .ToList();
                var childSuites = _testSuites
                                  .Where(ts => ts.ParentId.Equals(testSuite.Id) && !ts.ParentId.Equals("") && ts.Type.Equals("ParameterizedFixture")).ToList();
                foreach (var suite in childSuites)
                {
                    tests.AddRange(_testCases.Where(tc => tc.ParentId.Equals(suite.Id) && !tc.ParentId.Equals("")));
                }
                foreach (var test in tests)
                {
                    test.GhprTestOutput.SuiteOutput = testSuite.Output;
                    Reporter.DataWriterService.UpdateTestOutput(test.GhprTestRun.TestInfo, test.GhprTestOutput);
                }

                break;
            }

            case "test-run":
            {
                Reporter.RunFinished();
                Reporter.CleanUpJob();
                Reporter.TearDown();
                break;
            }
            }
        }