Inheritance: IJsonSerialize
Beispiel #1
0
        private TestRunState Run( ITestListener testListener, Runner runner, TestFilter filter)
        {
            var state = TestRunState.NoTests;

                     runner.RunAll(result =>{

                            testListener.TestFinished( new TestResult()
                                                                    {
                                                                        Name = String.Format("{0}.{1}",result.Test.Fixture.Name, result.Test.Name),
                                                                        FixtureType = ((Fixture)result.Test.Fixture).Type,
                                                                        StackTrace = result.Output,
                                                                        Method = ((Test)result.Test).Method,
                                                                        State = StateForResult(result.Kind),
                                                                        TimeSpan = result.EndTime - result.StartTime,
                                                                    });

                                    if(state == TestRunState.NoTests){
                                        switch (result.Kind)
                                        {
                                            case ResultKind.Fail:
                                                state = TestRunState.Failure;
                                                break;
                                            case ResultKind.Error:
                                                state = TestRunState.Error;
                                                break;
                                            default:
                                                state = TestRunState.Success;
                                                break;
                                        }
                                    } else if(state == TestRunState.Success || state == TestRunState.Failure){
                                        switch (result.Kind)
                                        {
                                            case ResultKind.Fail:
                                                state = TestRunState.Failure;
                                                break;
                                            case ResultKind.Error:
                                                state = TestRunState.Error;
                                                break;
                                        }
                                    }

                     }, filter);
            return state;
        }
Beispiel #2
0
        public static Runner Create(string platformId, IEnumerable<Assembly> assemblies)
        {
            var runner = new Runner(platformId);

            foreach (var assembly in assemblies)
            {
                var assemblyMeta = new AssemblyMeta(assembly);

                runner.Assemblies.Add(assemblyMeta);

                var generators = assembly.GetCustomAttributes(true)
                                         .OfType<TestFixtureDiscoveryAttributeBase>().ToList();
                generators.Add(new DefaultDiscovery());
                foreach (var generator in generators)
                {
                    foreach (var fixture in generator.Generator(assembly))
                    {
                        assemblyMeta.Fixtures.Add(fixture);

                        foreach (var testHarness in fixture.GetHarnesses())
                        {

                            int i = 0;
                            foreach (var constructorSet in fixture.ParameterSets())
                            {
                                int j = 0;
                                constructorSet.Index = i++;
                                foreach (var testSet in testHarness.ParameterSets())
                                {
                                    testSet.Index = j++;
                                    var test = new Test(fixture, constructorSet,
                                                        testHarness, testSet);
                                    fixture.Tests.Add(test);
                                    runner.Tests.Add(test);
                                }
                            }
                        }
                    }
                }
            }

            return runner;
        }