private void HandleTestFinish(RunPipe runPipe, ReportRun reportRun)
            {
                ITestCommand runPipeTestCommand;

                if (runPipeTestCommands.TryGetValue(runPipe, out runPipeTestCommand))
                {
                    ITestContext testContext = activeTestContexts[runPipeTestCommand];
                    activeTestContexts.Remove(runPipeTestCommand);

                    // Output all execution log contents.
                    // Note: ReportRun.Asserts is not actually populated by MbUnit so we ignore it.
                    if (reportRun.ConsoleOut.Length != 0)
                    {
                        testContext.LogWriter.ConsoleOutput.Write(reportRun.ConsoleOut);
                    }
                    if (reportRun.ConsoleError.Length != 0)
                    {
                        testContext.LogWriter.ConsoleError.Write(reportRun.ConsoleError);
                    }
                    foreach (ReportWarning warning in reportRun.Warnings)
                    {
                        testContext.LogWriter.Warnings.WriteLine(warning.Text);
                    }
                    if (reportRun.Exception != null)
                    {
                        testContext.LogWriter.Failures.WriteException(GetExceptionDataFromReportException(reportRun.Exception), "Exception");
                    }

                    // Finish up...
                    testContext.AddAssertCount(reportRun.AssertCount);
                    FinishStepWithReportRunResult(testContext, reportRun.Result);
                }

                progressMonitor.Worked(workUnit);
            }
            private void TestFinished(TestOutcome outcome, string fixtureName, string testName, int assertCount, ulong durationNanosec, string reason, TestContextCallback callback)
            {
                ITestCommand fixtureCommand;

                if (!testCommandsByName.TryGetValue(fixtureName, out fixtureCommand))
                {
                    return;
                }

                ITestCommand testCommand;
                ITestContext testContext = null;

                if (testCommandsByName.TryGetValue(fixtureName + @"." + testName, out testCommand))
                {
                    if (testContextStack.Peek().TestStep.Test == testCommand.Test)
                    {
                        // Remove our test context from the stack
                        testContext = testContextStack.Pop();
                    }
                }

                ITestContext fixtureContext = GetFixtureContext(fixtureCommand);

                if (testCommand != null)
                {
                    if (testContext == null)
                    {
                        testContext = testCommand.StartPrimaryChildStep(fixtureContext.TestStep);
                        testContext.LifecyclePhase = LifecyclePhases.Execute;
                        progressMonitor.SetStatus(testCommand.Test.Name);
                    }

                    TimeSpan?duration = null;
                    if (durationNanosec > 0)
                    {
                        // A tick is equal to 100 nanoseconds
                        duration = TimeSpan.FromTicks((long)(durationNanosec / 100UL));
                    }

                    if (callback != null)
                    {
                        callback(testContext);
                    }

                    testContext.AddAssertCount(assertCount);
                    testContext.FinishStep(outcome, duration);

                    progressMonitor.Worked(1);
                }
                else if (!String.IsNullOrEmpty(reason))
                {
                    MarkupStreamWriter log = fixtureContext.LogWriter.Failures;

                    using (log.BeginSection(Resources.CSUnitTestController_ResultMessageSectionName))
                    {
                        log.Write(reason);
                    }
                }
            }
Example #3
0
        public void AddAssertCount(int value)
        {
            Interlocked.Add(ref assertCount, value);

            if (parent != null)
            {
                parent.AddAssertCount(value);
            }
        }
Example #4
0
        private TestResult RunTestStep(ITestCommand testCommand, TestInfoData testStepInfo, TestStep parentTestStep, IProgressMonitor progressMonitor)
        {
            ITestContext   testContext    = testCommand.StartPrimaryChildStep(parentTestStep);
            TestStepResult testStepResult = repository.RunTest(testStepInfo);

            reporter.Run(testContext, testStepInfo, testStepResult);
            WriteToTestLog(testContext, testStepResult);
            testContext.AddAssertCount(testStepResult.AssertCount);
            progressMonitor.Worked(1);
            return(testContext.FinishStep(testStepResult.TestOutcome, testStepResult.Duration));
        }
        private static bool RunTestFixture(ITestCommand testCommand, ConcordionTest concordionTest, ITestStep parentTestStep)
        {
            ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep);

            // The magic happens here!
            var concordion = new ConcordionBuilder()
                             .WithSource(concordionTest.Source)
                             .WithTarget(concordionTest.Target)
                             .WithSpecificationListener(new GallioResultRenderer())
                             .Build();

            var  summary = concordion.Process(concordionTest.Resource, concordionTest.Fixture);
            bool passed  = !(summary.HasFailures || summary.HasExceptions);

            testContext.AddAssertCount((int)summary.SuccessCount + (int)summary.FailureCount);
            testContext.FinishStep(passed ? TestOutcome.Passed : TestOutcome.Failed, null);
            return(passed);
        }
            private void HandleTestOrSuiteFinished(NUnit.Core.TestResult nunitResult)
            {
                if (testContextStack.Count == 0)
                {
                    return;
                }

                ITestContext testContext = testContextStack.Peek();
                NUnitTest    test        = (NUnitTest)testContext.TestStep.Test;

                if (test.Test.TestName != nunitResult.Test.TestName)
                {
                    return;
                }

                testContextStack.Pop();

                progressMonitor.Worked(1);

                string logStreamName = nunitResult.ResultState == ResultState.Success ? MarkupStreamNames.Warnings : MarkupStreamNames.Failures;

                MarkupDocumentWriter logWriter = testContext.LogWriter;

                if (nunitResult.Message != null)
                {
                    using (logWriter[logStreamName].BeginSection(Resources.NUnitTestController_ResultMessageSectionName))
                        logWriter[logStreamName].Write(nunitResult.Message);
                }
                if (nunitResult.StackTrace != null)
                {
                    using (logWriter[logStreamName].BeginSection(Resources.NUnitTestController_ResultStackTraceSectionName))
                        using (logWriter[logStreamName].BeginMarker(Marker.StackTrace))
                            logWriter[logStreamName].Write(nunitResult.StackTrace);
                }

                testContext.AddAssertCount(nunitResult.AssertCount);
                TestResult result = testContext.FinishStep(CreateOutcomeFromResult(nunitResult), null);

                if (testContextStack.Count == 0)
                {
                    topResult = result;
                }
            }
Example #7
0
 /// <summary>
 /// Adds the specified amount to the assert count atomically.
 /// </summary>
 /// <param name="value">The amount to add to the assert count.</param>
 public void AddAssertCount(int value)
 {
     inner.AddAssertCount(value);
 }