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)); }
protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { using (progressMonitor) { 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; _progressMonitor = progressMonitor; SetupRunOptions(options); SetupListeners(options); _listener.OnRunStart(); foreach (ITestCommand command in rootTestCommand.Children) { MachineAssemblyTest assemblyTest = command.Test as MachineAssemblyTest; if (assemblyTest == null) { continue; } var assemblyResult = RunAssembly(assemblyTest, command, rootStep); outcome = outcome.CombineWith(assemblyResult.Outcome); } _listener.OnRunEnd(); return(rootContext.FinishStep(outcome, null)); } } }
Test GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, bool populateRecursively) { MachineAssemblyTest assemblyTest; if (!assemblyTests.TryGetValue(assembly, out assemblyTest)) { assemblyTest = new MachineAssemblyTest(assembly.Name, assembly, frameworkVersion); assemblyTest.Kind = TestKinds.Assembly; ModelUtils.PopulateMetadataFromAssembly(assembly, assemblyTest.Metadata); string frameworkName = String.Format("Machine Specifications 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) { AssemblyExplorer explorer = new AssemblyExplorer(); Assembly resolvedAssembly = assembly.Resolve(false); assemblyTest.AssemblyContexts = explorer.FindAssemblyContextsIn(resolvedAssembly).ToList(); assemblyTest.GlobalCleanup = explorer.FindAssemblyWideContextCleanupsIn(resolvedAssembly).ToList(); assemblyTest.SpecificationSupplements = explorer.FindSpecificationSupplementsIn(resolvedAssembly).ToList(); explorer.FindContextsIn(resolvedAssembly) .Select(context => GetContextTest(context)) .Each(test => assemblyTest.AddChild(test)); } return(assemblyTest); }