Beispiel #1
0
        public void duplicated_runs_dont_accidentally_accumulate_afterEach_calls()
        {
            AFixture fixture = new AFixture();

            var fakeGlobalSetupManager = new FakeGlobalSetupManager();

            TestPosition testPosition = TestPosition.At(1, 3, 2);

            var traceMessages = new List <string>();

            SpecificationRunner.RunTest(new TestContext()
            {
                FixtureContext = new FixtureContext(null, () => fixture, null, fakeGlobalSetupManager),
                Name           = new TestName(),
                Position       = testPosition
            }, traceMessages);

            fixture.ResetObservations();

            var traceMessages1 = new List <string>();

            SpecificationRunner.RunTest(new TestContext()
            {
                FixtureContext = new FixtureContext(null, () => fixture, null, fakeGlobalSetupManager),
                Name           = new TestName(),
                Position       = testPosition
            }, traceMessages1);

            expect_observation_matches(fixture.Observations, 1, 2, 3, 4, 5, 6, -2, -3, -4, 7, 8);
        }
Beispiel #2
0
        TestResult RunTest(EventListener listener)
        {
            listener.TestStarted(base.TestName);

            TestResult nunitTestResult = new TestResult(this);

            if (_pendingException != null)
            {
                nunitTestResult.Failure(_pendingException.Message, _pendingException.StackTrace, FailureSite.Test);
            }
            else if (RunState == RunState.NotRunnable)
            {
                nunitTestResult.SetResult(ResultState.NotRunnable, IgnoreReason, "", FailureSite.Test);
            }
            else
            {
                var testResult = SpecificationRunner.RunTest(this._testContext, new List <string>());

                NativeTestResult.ApplyToNunitResult(testResult, nunitTestResult);
            }

            listener.TestFinished(nunitTestResult);

            return(nunitTestResult);
        }
Beispiel #3
0
            public void RunTests(string assemblyName, string[] testNames, string explictlyIncluding, ITestResultListener listener)
            {
                using (var nativeTestFactory = RunTestDiscovery(Assembly.Load(assemblyName), t => true))
                {
                    foreach (var name in testNames)
                    {
                        var testContext = nativeTestFactory.Contexts[name];

                        var ignoreReason = nativeTestFactory.GetIgnoreReason(name, explictlyIncluding);

                        listener.NotifyStart(testContext.Name.FullName);

                        List <string> traceMessages = new List <string>();

                        if (ignoreReason == null)
                        {
                            var result = SpecificationRunner.RunTest(testContext, traceMessages);

                            listener.NotifyEnd(testContext.Name.FullName, result);
                        }
                        else
                        {
                            var result = new TestResultShim();
                            result.SetSkipped(ignoreReason);
                            listener.NotifyEnd(testContext.Name.FullName, result);
                        }
                    }
                }
            }
        void expect_test_to_observe(TestPosition testPosition, List <string> expected)
        {
            var fixture = new has_test_in_loop();

            var traceMessages = new List <string>();

            SpecificationRunner.RunTest(new TestContext()
            {
                FixtureContext = new FixtureContext(null, () => fixture, null, new FakeGlobalSetupManager()),
                Name           = new TestName(),
                Position       = testPosition
            }, traceMessages);


            Assert.That(fixture.Observations, Is.EquivalentTo(expected));
        }
Beispiel #5
0
        public void can_be_ran()
        {
            AFixture fixture = new AFixture();

            var fakeGlobalSetupManager = new FakeGlobalSetupManager();

            var traceMessages = new List <string>();

            SpecificationRunner.RunTest(new TestContext()
            {
                FixtureContext = new FixtureContext(null, () => fixture, null, fakeGlobalSetupManager),
                Name           = new TestName(),
                Position       = TestPosition.At(1, 3, 2)
            }, traceMessages);

            expect_observation_matches(fixture.Observations, 1, 2, 3, 4, 5, 6, 7, -2, -3, -4, 8);
        }