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 AfterTest(ITest nunitTest)
 {
     if (!nunitTest.IsSuite)
     {
         var ghprTest = TestRunHelper.GetTestRunOnFinished(GetTestNode(nunitTest));
         Reporter.TestFinished(ghprTest);
     }
 }
Exemplo n.º 3
0
 public void AfterTest(ITest nunitTest)
 {
     if (!nunitTest.IsSuite)
     {
         var ghprTest = TestRunHelper.GetTestRunOnFinished(GetTestNode(nunitTest), DateTime.UtcNow, Reporter.Logger);
         Reporter.TestFinished(ghprTest.GhprTestRun, ghprTest.GhprTestOutput);
     }
 }
Exemplo n.º 4
0
        private ITestRun GetGhprTestRun(ITest nunitTest)
        {
            var testXml = nunitTest.ToXml(true).OuterXml;
            var xDoc    = new XmlDocument();

            xDoc.LoadXml(testXml);
            var testRun = TestRunHelper.GetTestRun(xDoc.DocumentElement);

            return(testRun);
        }
Exemplo n.º 5
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.º 6
0
 public void BeforeTest(ITest nunitTest)
 {
     if (!Reporter.TestRunStarted)
     {
         Reporter.RunStarted();
     }
     if (!nunitTest.IsSuite)
     {
         var ghprTest = TestRunHelper.GetTestRunOnStarted(GetTestNode(nunitTest), DateTime.Now, Reporter.Logger);
         Reporter.TestFinished(ghprTest.GhprTestRun, ghprTest.GhprTestOutput);
     }
 }
Exemplo n.º 7
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.GetTestRun(xmlNode));
                break;
            }

            case "test-case":
            {
                _reporter.TestFinished(TestRunHelper.GetTestRun(xmlNode));
                break;
            }

            default:
            {
                //Log.Warning($"Unknown XML Node! Node name: '{xmlNode.Name}'");
                break;
            }
            }
        }
Exemplo n.º 8
0
        private void TestRunWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var           worker        = sender as BackgroundWorker;
            var           listViewItem  = e.Argument as ListViewItem;
            TestRunHelper testRunHelper = null;

            if (listViewItem != null)
            {
                var test = listViewItem.Tag as Test;
                testRunHelper = new TestRunHelper {
                    ListViewItem = listViewItem
                };
                worker.ReportProgress(1, test.TestName);
                if (_formClosing)
                {
                    return;
                }

                try
                {
                    testRunHelper.StartTime = DateTime.Now;
                    if (test.Enabled)
                    {
                        Console.WriteLine(@"Test Executed : " + test.TestName);
                        test.Run();
                        testRunHelper.StopTime = DateTime.Now;
                    }
                }
                catch (Exception exception)
                {
                    testRunHelper.StopTime  = DateTime.Now;
                    testRunHelper.Exception = exception;
                }
                worker.ReportProgress(1, test.TestName);
            }
            e.Result = testRunHelper;
        }
        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.º 10
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;
            }
            }
        }