protected TestPlanBase(DefaultTestRunner runner, TestRun testRun, TestRunnerOptions normalized)
            {
                _normalizedOpts = normalized;
                _runner         = runner;
                _root           = new RootNode(runner, testRun);
                _root.Initialize();

                normalized.PreviousRun.ApplyTo(testRun);
                if (normalized.RerunPreviousFailures)
                {
                    if (normalized.PreviousRun.FailureReason.IsFailure())
                    {
                        normalized.PlanFilter.Tags.Add(
                            TestTagPredicate.Previously(TestStatus.Failed)
                            );
                    }
                    else
                    {
                        Log.Warn("No previous failures, re-running all tests...");
                    }
                }

                // Apply filter rules from the options
                _normalizedOpts.PlanFilter.Apply(testRun, normalized);

                _willRun = PlanOrder.Where(p => p.IsLeafThatWillRun).Select(n => (TestCaseInfo)n.Unit).ToList();
            }
Example #2
0
 internal virtual void Done(TestUnit unit, TestRunnerOptions opts)
 {
     if (Children.Count == 0)
     {
         _status = TestUnit.ConvertToStatus(unit).GetValueOrDefault(TestStatus.Passed);
     }
     else
     {
         _status = Children.Status;
     }
 }
Example #3
0
        protected TestRunner(TestRunnerOptions options)
        {
            Options = options.Clone();

            // HACK -- This is unsealed when the self-tests run because it could be modified
            // to facilitate runner-specific test setup (e.g. DSLGrammarTests)
            if (!Options.SelfTest)
            {
                Options.MakeReadOnly();
            }
            SessionId = Utility.RandomName();
        }
Example #4
0
        internal void Apply(TestRun testRun, TestRunnerOptions normalized) {
            ActivateDefaultTestSet(testRun);

            Excludes.Apply(testRun, SKIP);
            FocusPatterns.Apply(testRun, FOCUS);

            // If any focused nodes, then only run focused nodes
            if (!normalized.IgnoreFocus && testRun.ContainsFocusedUnits) {
                ApplyFocussing(testRun);
            }

            InheritBiasToChildren(testRun);
            SealRecursive(testRun);
        }
Example #5
0
 internal override void Done(TestUnit unit, TestRunnerOptions opts)
 {
     _finishedAt = DateTime.Now;
     if (Status == TestStatus.NotRun)
     {
         SetSuccess();
     }
     if (unit != null && unit.IsFocused)
     {
         _flags |= Flags.Focused;
     }
     if (opts.SlowTestThreshold.HasValue && ExecutionTime >= opts.SlowTestThreshold.Value)
     {
         _flags |= Flags.Slow;
     }
 }
Example #6
0
        internal TestRunnerOptions Normalize()
        {
            var result = new TestRunnerOptions(this);

            if (result.RandomSeed <= 0)
            {
                result.RandomSeed = Environment.TickCount;
            }
            if (result.ContextLines < 0)
            {
                result.ContextLines = 3; // default
            }
            if (!result.SlowTestThreshold.HasValue)
            {
                result.SlowTestThreshold = TimeSpan.FromMilliseconds(500);
            }
            result.MakeReadOnly();
            return(result);
        }
Example #7
0
        internal TestRunProblems(IEnumerable <TestUnitResult> descendants, TestRunnerOptions opts)
        {
            foreach (var item in descendants)
            {
                if (item.Children.Count > 0)
                {
                    // Because statuses rollup into the composite result (e.g. if composite contains
                    // only failed tests, then it rolls up as failed),
                    // only report composite results as a problem if there is a setup error.
                    bool ignoreProblem = item.ExceptionInfo == null && item.Messages.Count == 0;
                    if (ignoreProblem)
                    {
                        continue;
                    }
                }
                if (item.IsPending)
                {
                    _pending.Add(item);
                }
                else if (item.Failed)
                {
                    _failures.Add(item);
                }
                else if (item.IsSlow)
                {
                    _slow.Add(item);
                }
            }

            int ordinal = 1;

            foreach (var f in _failures)
            {
                f.Ordinal = ordinal++;
            }
            foreach (var f in _slow)
            {
                f.Ordinal = ordinal++;
            }
        }
Example #8
0
        public TestRunnerOptions(TestRunnerOptions copyFrom)
        {
            if (copyFrom == null)
            {
                return;
            }

            IgnoreFocus = copyFrom.IgnoreFocus;
            FixturePaths.AddAll(copyFrom.FixturePaths);
            LoaderPaths.AddAll(copyFrom.LoaderPaths);
            LoadAssemblyFromPath = copyFrom.LoadAssemblyFromPath;
            RandomSeed           = copyFrom.RandomSeed;
            _flags       = copyFrom._flags;
            ContextLines = copyFrom.ContextLines;
            SelfTest     = copyFrom.SelfTest;
            PackageReferences.AddAll(copyFrom.PackageReferences);
            PlanFilter.CopyFrom(copyFrom.PlanFilter);
            TestTimeout                = copyFrom.TestTimeout;
            PlanTimeout                = copyFrom.PlanTimeout;
            SlowTestThreshold          = copyFrom.SlowTestThreshold;
            AssertionMessageFormatMode = copyFrom.AssertionMessageFormatMode;
            PreviousRun                = copyFrom.PreviousRun;
        }
Example #9
0
 internal void CopyToOptions(TestRunnerOptions testRunnerOptions)
 {
     testRunnerOptions.PreviousRun = Results;
 }
Example #10
0
 internal TestRunnerStartingEventArgs(TestRunnerOptions options, TestRun run, int willRunTests)
 {
     _options      = options;
     _willRunTests = willRunTests;
     TestRun       = run;
 }
Example #11
0
 public DefaultTestRunner(TestRunnerOptions opts) : base(opts.Normalize())
 {
     _messageLogger = new BufferMessageEventCache();
     Logger         = new ConsoleLogger(opts);
 }
 internal TestRunnerFinishedEventArgs(TestRun testRun, TestRunResults results, TestRunnerOptions opts)
 {
     Results = results;
     TestRun = testRun;
     _opts   = opts;
 }
Example #13
0
 public static TestRunner Create(TestRunnerOptions testRunnerOptions)
 {
     return(new DefaultTestRunner(testRunnerOptions));
 }