Esempio n. 1
0
        public void ShouldAllowRandomShufflingOfCaseExecutionOrder()
        {
            var listener = new StubListener();

            var candidateTypes = new[]
            {
                typeof(SampleIrrelevantClass), typeof(PassTestClass), typeof(int),
                typeof(PassFailTestClass), typeof(SkipTestClass)
            };
            var discovery = new SelfTestDiscovery();
            var execution = new CreateInstancePerClass();

            discovery.Methods
            .Shuffle(new Random(1));

            var bus = new Bus(listener);

            new Runner(GetType().Assembly, bus).Run(candidateTypes, discovery, execution);

            listener.Entries.ShouldBe(
                Self + "+PassTestClass.PassB passed",
                Self + "+PassTestClass.PassA passed",
                Self + "+PassFailTestClass.Fail failed: 'Fail' failed!",
                Self + "+PassFailTestClass.Pass passed",
                Self + "+SkipTestClass.SkipB skipped",
                Self + "+SkipTestClass.SkipA skipped");
        }
Esempio n. 2
0
        public void ShouldReportFailuresForAllAffectedCasesWithoutShortCircuitingTestExecutionWhenCaseOrderingThrows()
        {
            var listener = new StubListener();

            var candidateTypes = new[]
            {
                typeof(SampleIrrelevantClass), typeof(PassTestClass), typeof(int),
                typeof(PassFailTestClass), typeof(SkipTestClass), typeof(BuggyParameterGenerationTestClass)
            };
            var discovery = new SelfTestDiscovery();
            var execution = new CreateInstancePerClass();

            discovery.Methods
            .OrderBy((Func <MethodInfo, string>)(x => throw new Exception("OrderBy lambda expression threw!")));

            discovery.Parameters
            .Add <BuggyParameterSource>();

            var bus = new Bus(listener);

            new Runner(GetType().Assembly, bus).Run(candidateTypes, discovery, execution);

            //NOTE: Since the ordering of cases is deliberately failing, and since member order via reflection
            //      is undefined, we explicitly sort the listener Entries here to avoid making a brittle assertion.

            var strings = listener.Entries.OrderBy(x => x).ToArray();

            strings.ShouldBe(
                Self + "+BuggyParameterGenerationTestClass.ParameterizedA failed: Exception thrown while attempting to yield input parameters for method: ParameterizedA",
                Self + "+BuggyParameterGenerationTestClass.ParameterizedA failed: OrderBy lambda expression threw!",
                Self + "+BuggyParameterGenerationTestClass.ParameterizedB failed: Exception thrown while attempting to yield input parameters for method: ParameterizedB",
                Self + "+BuggyParameterGenerationTestClass.ParameterizedB failed: OrderBy lambda expression threw!",
                Self + "+PassFailTestClass.Fail failed: 'Fail' failed!",
                Self + "+PassFailTestClass.Fail failed: OrderBy lambda expression threw!",
                Self + "+PassFailTestClass.Pass failed: OrderBy lambda expression threw!",
                Self + "+PassFailTestClass.Pass passed",
                Self + "+PassTestClass.PassA failed: OrderBy lambda expression threw!",
                Self + "+PassTestClass.PassA passed",
                Self + "+PassTestClass.PassB failed: OrderBy lambda expression threw!",
                Self + "+PassTestClass.PassB passed",
                Self + "+SkipTestClass.SkipA failed: OrderBy lambda expression threw!",
                Self + "+SkipTestClass.SkipA skipped",
                Self + "+SkipTestClass.SkipB failed: OrderBy lambda expression threw!",
                Self + "+SkipTestClass.SkipB skipped");
        }
Esempio n. 3
0
        public void ShouldExecuteAllCasesInAllDiscoveredTestClasses()
        {
            var listener = new StubListener();

            var discovery = new SelfTestDiscovery();
            var execution = new CreateInstancePerClass();

            var bus = new Bus(listener);

            new Runner(bus).RunTypes(GetType().Assembly, discovery, execution,
                                     typeof(SampleIrrelevantClass), typeof(PassTestClass), typeof(int),
                                     typeof(PassFailTestClass), typeof(SkipTestClass));

            listener.Entries.ShouldEqual(
                Self + "+PassTestClass.PassA passed",
                Self + "+PassTestClass.PassB passed",
                Self + "+PassFailTestClass.Fail failed: 'Fail' failed!",
                Self + "+PassFailTestClass.Pass passed",
                Self + "+SkipTestClass.SkipA skipped",
                Self + "+SkipTestClass.SkipB skipped");
        }