MachineContextTest GetContextTest(Context context) { MachineContextTest contextTest = new MachineContextTest(context); context.Specifications .Select(spec => GetSpecificationTest(context, spec)) .Each(test => contextTest.AddChild(test)); if (context.Subject != null) { contextTest.Metadata.Add(MetadataKeys.Category, context.Subject.FullConcern); } if (context.Tags != null && context.Tags.Any()) { contextTest.Metadata.Add(SpecificationMetadataKeys.Tags, context.Tags.Select(t => t.Name).ToList()); } if (context.IsIgnored) { contextTest.Metadata.Add(MetadataKeys.IgnoreReason, "The context has the IgnoreAttribute"); } AddXmlComment(contextTest, Reflector.Wrap(context.Type)); return(contextTest); }
TestResult RunAssembly(MachineAssemblyTest assemblyTest, ITestCommand command, TestStep parentTestStep) { ITestContext assemblyContext = command.StartPrimaryChildStep(parentTestStep); AssemblyInfo assemblyInfo = new AssemblyInfo(assemblyTest.Name, assemblyTest.AssemblyFilePath); TestOutcome outcome = TestOutcome.Passed; _listener.OnAssemblyStart(assemblyInfo); assemblyTest.AssemblyContexts.Each(context => context.OnAssemblyStart()); foreach (ITestCommand contextCommand in command.Children) { MachineContextTest contextTest = contextCommand.Test as MachineContextTest; if (contextTest == null) { continue; } var contextResult = RunContextTest(assemblyTest, contextTest, contextCommand, assemblyContext.TestStep); outcome = outcome.CombineWith(contextResult.Outcome); assemblyContext.SetInterimOutcome(outcome); } assemblyTest.AssemblyContexts.Reverse().Each(context => context.OnAssemblyComplete()); _listener.OnAssemblyEnd(assemblyInfo); return(assemblyContext.FinishStep(outcome, null)); }
TestResult RunContextTest(MachineAssemblyTest assemblyTest, MachineContextTest contextTest, ITestCommand command, TestStep parentTestStep) { ITestContext testContext = command.StartPrimaryChildStep(parentTestStep); GallioRunListener listener = new GallioRunListener(_listener, _progressMonitor, testContext, command.Children); IContextRunner runner = ContextRunnerFactory.GetContextRunnerFor(contextTest.Context); runner.Run(contextTest.Context, listener, _options, assemblyTest.GlobalCleanup, assemblyTest.SpecificationSupplements); return(testContext.FinishStep(listener.Outcome, null)); }