protected override ReportRunResult RunFixture(Fixture fixture)
            {
                CheckCanceled();

                try
                {
                    HandleFixtureStart(fixture);

                    foreach (RunPipeStarter starter in fixture.Starters)
                    {
                        starter.Listeners.Add(this);
                    }

                    ReportRunResult reportRunResult = base.RunFixture(fixture);
                    HandleFixtureFinish(fixture, reportRunResult);

                    return(reportRunResult);
                }
                finally
                {
                    foreach (RunPipeStarter starter in fixture.Starters)
                    {
                        if (starter.Listeners.Contains(this))
                        {
                            starter.Listeners.Remove(this);
                        }
                    }
                }
            }
        protected override void RunFixtures()
        {
            // setup result
            foreach (FixtureVertex v in this.FixtureGraph.Graph.Vertices)
            {
                v.Result = ReportRunResult.NotRun;
            }

            // topological sort
            TopologicalSortAlgorithm topo = new TopologicalSortAlgorithm(this.FixtureGraph.Graph);
            ArrayList list = new ArrayList();

            topo.Compute(list);

            // execute pipes
            foreach (FixtureVertex v in list)
            {
                // result failed
                if (v.Result != ReportRunResult.NotRun)
                {
                    ReportMonitor monitor           = new ReportMonitor();
                    ParentFixtureFailedException ex = new ParentFixtureFailedException();
                    foreach (Fixture fixture in v.Fixtures)
                    {
                        if (!this.FilterFixture(fixture))
                        {
                            continue;
                        }
                        this.SkipStarters(fixture, ex);
                    }
                }
                else
                {
                    // run fixtures
                    v.Result = ReportRunResult.Success;
                    foreach (Fixture fixture in v.Fixtures)
                    {
                        if (!this.FilterFixture(fixture))
                        {
                            continue;
                        }
                        ReportRunResult result = RunFixture(fixture);
                        if (result != ReportRunResult.Success && v.Result != ReportRunResult.Failure)
                        {
                            v.Result = result;
                        }
                    }
                }

                // update children if failed
                if (v.Result != ReportRunResult.Success)
                {
                    foreach (FixtureVertex target in this.FixtureGraph.Graph.AdjacentVertices(v))
                    {
                        target.Result = v.Result;
                    }
                }
            }
        }
Example #3
0
 public void Start()
 {
     try
     {
         this.result = this.runner.InternalRunFixture(this.fixture);
     }
     catch (Exception ex)
     {
         this.throwedException = ex;
     }
 }
            private void FinishStepWithReportRunResult(ITestContext testContext, ReportRunResult reportRunResult)
            {
                TestOutcome outcome = GetOutcomeFromReportRunResult(reportRunResult);

                testContext.FinishStep(outcome, null);

                // only update assembly status if more severe
                if (outcome.Status > assemblyTestOutcome.Status)
                {
                    assemblyTestOutcome = outcome;
                }
            }
            private void HandleFixtureFinish(Fixture fixture, ReportRunResult reportRunResult)
            {
                ITestCommand fixtureTestCommand;

                if (!fixtureTestCommands.TryGetValue(fixture, out fixtureTestCommand))
                {
                    return;
                }

                ITestContext fixtureTestContext = activeTestContexts[fixtureTestCommand];

                activeTestContexts.Remove(fixtureTestCommand);

                FinishStepWithReportRunResult(fixtureTestContext, reportRunResult);
            }
            private static TestOutcome GetOutcomeFromReportRunResult(ReportRunResult reportRunResult)
            {
                switch (reportRunResult)
                {
                case ReportRunResult.NotRun:
                case ReportRunResult.Skip:
                    return(TestOutcome.Skipped);

                case ReportRunResult.Ignore:
                    return(TestOutcome.Ignored);

                case ReportRunResult.Success:
                    return(TestOutcome.Passed);

                case ReportRunResult.Failure:
                    return(TestOutcome.Failed);

                default:
                    throw new ArgumentException("Unsupported report run result.", "reportRunResult");
                }
            }
Example #7
0
 public void Start()
 {
     try
     {
         this.result = this.runner.InternalRunFixture(this.fixture);
     }
     catch (Exception ex)
     {
         this.throwedException = ex;
     }
 }
Example #8
0
        private ReportRunResult InternalRunFixture(Fixture fixture)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException("fixture");
            }


            Object          fixtureInstance = null;
            ReportRunResult result          = ReportRunResult.Success;

            try
            {
                fixtureInstance = CreateFixtureInstance(fixture);
                if (fixtureInstance == null)
                {
                    return(ReportRunResult.Failure);
                }

                // aborting if requested
                if (this.IsAbortPending)
                {
                    return(ReportRunResult.Failure);
                }

                fixtureInstance = RunFixtureSetUp(fixture, fixtureInstance);
                if (fixtureInstance == null)
                {
                    return(ReportRunResult.Failure);
                }

                // aborting if requested
                if (this.IsAbortPending)
                {
                    return(ReportRunResult.Failure);
                }

                this.CurrentPipeStarter = null;
                foreach (RunPipeStarter starter in fixture.Starters)
                {
                    if (!this.FilterRunPipe(starter))
                    {
                        continue;
                    }
                    // aborting if requested
                    if (this.IsAbortPending)
                    {
                        return(ReportRunResult.Failure);
                    }
                    this.CurrentPipeStarter = starter;
                    starter.Run(fixtureInstance, this.IsExplicit);
                    OnRunResult(new ReportRunEventArgs(starter.Result));
                    if (starter.Result.Result != ReportRunResult.Success && result != ReportRunResult.Failure)
                    {
                        result = starter.Result.Result;
                    }
                }
            }
            finally
            {
                this.CurrentPipeStarter = null;
                if (fixtureInstance != null)
                {
                    RunFixtureTearDown(fixture, fixtureInstance);
                }
            }

            return(result);
        }
            private static TestOutcome GetOutcomeFromReportRunResult(ReportRunResult reportRunResult)
            {
                switch (reportRunResult)
                {
                    case ReportRunResult.NotRun:
                    case ReportRunResult.Skip:
                        return TestOutcome.Skipped;

                    case ReportRunResult.Ignore:
                        return TestOutcome.Ignored;

                    case ReportRunResult.Success:
                        return TestOutcome.Passed;

                    case ReportRunResult.Failure:
                        return TestOutcome.Failed;

                    default:
                        throw new ArgumentException("Unsupported report run result.", "reportRunResult");
                }
            }
            private void FinishStepWithReportRunResult(ITestContext testContext, ReportRunResult reportRunResult)
            {
                TestOutcome outcome = GetOutcomeFromReportRunResult(reportRunResult);
                testContext.FinishStep(outcome, null);

                // only update assembly status if more severe
                if (outcome.Status > assemblyTestOutcome.Status)
                    assemblyTestOutcome = outcome;
            }
            private void HandleFixtureFinish(Fixture fixture, ReportRunResult reportRunResult)
            {
                ITestCommand fixtureTestCommand;
                if (!fixtureTestCommands.TryGetValue(fixture, out fixtureTestCommand))
                    return;

                ITestContext fixtureTestContext = activeTestContexts[fixtureTestCommand];
                activeTestContexts.Remove(fixtureTestCommand);

                FinishStepWithReportRunResult(fixtureTestContext, reportRunResult);
            }