コード例 #1
0
ファイル: NSpecTestExplorer.cs プロジェクト: kina/NSpec
        Test GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, bool populateRecursively)
        {
            NSpecAssemblyTest assemblyTest;

            if (!assemblyTests.TryGetValue(assembly, out assemblyTest))
            {
                assemblyTest      = new NSpecAssemblyTest(assembly.Name, assembly, frameworkVersion);
                assemblyTest.Kind = TestKinds.Assembly;

                ModelUtils.PopulateMetadataFromAssembly(assembly, assemblyTest.Metadata);

                string frameworkName = String.Format("NSpec v{0}", frameworkVersion);
                assemblyTest.Metadata.SetValue(MetadataKeys.Framework, frameworkName);
                assemblyTest.Metadata.SetValue(MetadataKeys.File, assembly.Path);
                assemblyTest.Kind = TestKinds.Assembly;

                parentTest.AddChild(assemblyTest);
                assemblyTests.Add(assembly, assemblyTest);
            }

            if (populateRecursively)
            {
                var reflector = new NSpec.Domain.Reflector(assembly.Path);
                var finder    = new SpecFinder(reflector);
                var builder   = new ContextBuilder(finder, new DefaultConventions());

                ContextCollection contexts = builder.Contexts();
                contexts.Build();
                contexts.Do(c => assemblyTest.AddChild(this.CreateGallioTestFrom(c)));
            }

            return(assemblyTest);
        }
コード例 #2
0
ファイル: NSpecController.cs プロジェクト: kina/NSpec
        protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask("Verifying Specifications", rootTestCommand.TestCount))
            {
                if (options.SkipTestExecution)
                {
                    return(SkipAll(rootTestCommand, parentTestStep));
                }
                else
                {
                    ITestContext rootContext = rootTestCommand.StartPrimaryChildStep(parentTestStep);
                    TestStep     rootStep    = rootContext.TestStep;
                    TestOutcome  outcome     = TestOutcome.Passed;

                    foreach (ITestCommand command in rootTestCommand.Children)
                    {
                        NSpecAssemblyTest assemblyTest = command.Test as NSpecAssemblyTest;
                        if (assemblyTest == null)
                        {
                            continue;
                        }

                        var assemblyResult = this.RunAssembly(command, rootStep);
                        outcome = outcome.CombineWith(assemblyResult.Outcome);
                    }

                    return(rootContext.FinishStep(outcome, null));
                }
            }
        }