/// <inheritdoc /> protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { ThrowIfDisposed(); using (progressMonitor.BeginTask(Resources.MbUnit2TestController_RunningMbUnitTests, 1)) { if (progressMonitor.IsCanceled) return new TestResult(TestOutcome.Canceled); if (options.SkipTestExecution) { return SkipAll(rootTestCommand, parentTestStep); } else { IList<ITestCommand> testCommands = rootTestCommand.GetAllCommands(); using (InstrumentedFixtureRunner fixtureRunner = new InstrumentedFixtureRunner(fixtureExplorer, testCommands, progressMonitor, parentTestStep)) { return fixtureRunner.Run(); } } } }
private TestResult RunContext( NSpecContextTest contextTest, ITestCommand command, TestStep testStep ) { ITestContext testContext = command.StartPrimaryChildStep( testStep ); TestOutcome outcome = TestOutcome.Passed; foreach( ITestCommand testCommand in command.Children ) { NSpecExampleTest exampleTest = testCommand.Test as NSpecExampleTest; if( exampleTest == null ) { continue; } outcome = outcome.CombineWith( this.RunTest( contextTest, exampleTest, testCommand, testContext.TestStep ).Outcome ); } foreach( ITestCommand testCommand in command.Children ) { NSpecContextTest contextTestChild = testCommand.Test as NSpecContextTest; if( contextTestChild == null ) { continue; } outcome = outcome.CombineWith( this.RunContext( contextTestChild, testCommand, testContext.TestStep ).Outcome ); } return testContext.FinishStep( outcome, null ); }
protected internal override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount)) { return RunTest(rootTestCommand, parentTestStep, options, progressMonitor); } }
private TestResult RunTest(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor) { Test test = testCommand.Test; progressMonitor.SetStatus(test.Name); // The first test should be an assembly test MSTestAssembly assemblyTest = testCommand.Test as MSTestAssembly; TestOutcome outcome; TestResult result; if (assemblyTest != null) { ITestContext assemblyContext = testCommand.StartPrimaryChildStep(parentTestStep); try { MSTestRunner runner = MSTestRunner.GetRunnerForFrameworkVersion(frameworkVersion); outcome = runner.RunSession(assemblyContext, assemblyTest, testCommand, parentTestStep, progressMonitor); } catch (Exception ex) { assemblyContext.LogWriter.Failures.WriteException(ex, "Internal Error"); outcome = TestOutcome.Error; } result = assemblyContext.FinishStep(outcome, null); } else { result = new TestResult(TestOutcome.Skipped); } progressMonitor.Worked(1); return result; }
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 ); } } }
protected internal override TestResult RunImpl(ITestCommand rootTestCommand, Model.Tree.TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount)) { // Note: We do not check options.SkipTestExecution here because we want to build up // the tree of data-driven test steps. So we actually check it later on in the // PatternTestExecutor. This is different from framework adapters // at this time (because they do not generally support dynamically generated data-driven tests). Sandbox sandbox = new Sandbox(); EventHandler canceledHandler = delegate { sandbox.Abort(TestOutcome.Canceled, "The user canceled the test run."); }; try { progressMonitor.Canceled += canceledHandler; TestAssemblyExecutionParameters.Reset(); PatternTestExecutor executor = new PatternTestExecutor(options, progressMonitor, formatter, converter, environmentManager); // Inlined to minimize stack depth. var action = executor.CreateActionToRunTest(rootTestCommand, parentTestStep, sandbox, null); action.Run(); return action.Result; } finally { progressMonitor.Canceled -= canceledHandler; sandbox.Dispose(); } } }
public void SetUp() { testCommand = MockRepository.GenerateStub<ITestCommand>(); testName = new TestName { TestID = new TestID(), FullName = "fullName" }; var testCommandsByTestName = new Dictionary<TestName, ITestCommand> { { testName, testCommand } }; testFilter = new NUnitTestFilter(testCommandsByTestName); test = MockRepository.GenerateStub<ITest>(); }
static bool OnTestStart(ITestCommand command, ExecutorCallback callback) { XmlNode node = command.ToStartXml(); if (node != null) callback.Notify(node.OuterXml); return callback.ShouldContinue(); }
public NuwaTestCommand(ITestCommand innerCommand) { if (innerCommand == null) { throw new ArgumentNullException("innerCommand"); } _proxy = innerCommand; }
private static TestResult RunChildTests(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor) { ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep); bool passed = true; foreach (ITestCommand child in testCommand.Children) passed &= RunTest(child, testContext.TestStep, progressMonitor).Outcome.Status == TestStatus.Passed; return testContext.FinishStep(passed ? TestOutcome.Passed : TestOutcome.Failed, null); }
private void RunAll(IProgressMonitor progressMonitor, ITestCommand rootTestCommand) { using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1)) { using (subProgressMonitor.BeginTask("Running the tests.", rootTestCommand.TestCount)) { RunTest(rootTestCommand, null, subProgressMonitor); } } }
/// <summary> /// Runs the tests. /// </summary> /// <remarks> /// <para> /// This method can be called at most once during the lifetime of a test controller. /// </para> /// </remarks> /// <param name="rootTestCommand">The root test monitor.</param> /// <param name="parentTestStep">The parent test step, or null if starting a root step.</param> /// <param name="options">The test execution options.</param> /// <param name="progressMonitor">The progress monitor.</param> /// <returns>The combined result of the root test command.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="rootTestCommand"/> /// <paramref name="progressMonitor"/>, or <paramref name="options"/> is null.</exception> public TestResult Run(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { if (rootTestCommand == null) throw new ArgumentNullException("rootTestCommand"); if (progressMonitor == null) throw new ArgumentNullException("progressMonitor"); if (options == null) throw new ArgumentNullException("options"); return RunImpl(rootTestCommand, parentTestStep, options, progressMonitor); }
public void WrapsPassedInCommandIntoFixtureCommand([Frozen] Dictionary<MethodInfo, object> fixtures, FixtureSet sut, ITestCommand command) { var result = sut.ApplyFixturesToCommand(command); Assert.IsType<FixtureCommand>(result); var fixtureCommand = (FixtureCommand) result; Assert.Same(command, fixtureCommand.InnerCommand); //can't do anything else since fixtures property is not exposed var savedFixtures = typeof (FixtureCommand).GetField("fixtures", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fixtureCommand); Assert.Same(fixtures, savedFixtures); }
static bool OnTestStart(ITestCommand command, ICallbackEventHandler callback) { if (callback == null) return true; XmlNode node = command.ToStartXml(); if (node != null) callback.RaiseCallbackEvent(node.OuterXml); return bool.Parse(callback.GetCallbackResult()); }
private TestResult RunTest(ITestCommand testCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { // NOTE: This method has been optimized to minimize the total stack depth of the action // by inlining blocks on the critical path that had previously been factored out. using (TestController testController = testControllerProvider(testCommand.Test)) { if (testController != null) { try { using (IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(testCommand.TestCount)) { // Calling RunImpl directly instead of Run to minimize stack depth // because we already know the arguments are valid. return testController.RunImpl(testCommand, parentTestStep, options, subProgressMonitor); } } catch (Exception ex) { ITestContext context = testCommand.StartPrimaryChildStep(parentTestStep); context.LogWriter.Failures.WriteException(ex, "Fatal Exception in test controller"); return context.FinishStep(TestOutcome.Error, null); } } } // Enter the scope of the test and recurse until we find a controller. progressMonitor.SetStatus(testCommand.Test.FullName); ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep); TestOutcome outcome = TestOutcome.Passed; foreach (ITestCommand monitor in testCommand.Children) { if (progressMonitor.IsCanceled) break; TestResult childResult = RunTest(monitor, testContext.TestStep, options, progressMonitor); outcome = outcome.CombineWith(childResult.Outcome).Generalize(); } if (progressMonitor.IsCanceled) outcome = TestOutcome.Canceled; TestResult result = testContext.FinishStep(outcome, null); progressMonitor.Worked(1); return result; }
protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { using (progressMonitor.BeginTask(Resources.XunitTestController_RunningXunitTests, rootTestCommand.TestCount)) { if (options.SkipTestExecution) { return SkipAll(rootTestCommand, parentTestStep); } else { return RunTest(rootTestCommand, parentTestStep, progressMonitor); } } }
public TestOutcome RunSession(ITestContext assemblyTestContext, MSTestAssembly assemblyTest, ITestCommand assemblyTestCommand, TestStep parentTestStep, IProgressMonitor progressMonitor) { DirectoryInfo tempDir = SpecialPathPolicy.For("MSTestAdapter").CreateTempDirectoryWithUniqueName(); try { // Set the test results path. Among other things, the test results path // will determine where the deployed test files go. string testResultsPath = Path.Combine(tempDir.FullName, "tests.trx"); // Set the test results root directory. // This path determines both where MSTest searches for test files which // is used to resolve relative paths to test files in the "*.vsmdi" file. string searchPathRoot = Path.GetDirectoryName(assemblyTest.AssemblyFilePath); // Set the test metadata and run config paths. These are just temporary // files that can go anywhere on the filesystem. It happens to be convenient // to store them in the same temporary directory as the test results. string testMetadataPath = Path.Combine(tempDir.FullName, "tests.vsmdi"); string runConfigPath = Path.Combine(tempDir.FullName, "tests.runconfig"); progressMonitor.SetStatus("Generating test metadata file."); CreateTestMetadataFile(testMetadataPath, GetTestsFromCommands(assemblyTestCommand.PreOrderTraversal), assemblyTest.AssemblyFilePath); progressMonitor.SetStatus("Generating run config file."); CreateRunConfigFile(runConfigPath); progressMonitor.SetStatus("Executing tests."); Executor executor = new Executor(this, assemblyTestContext, assemblyTestCommand); TestOutcome outcome = executor.Execute(testMetadataPath, testResultsPath, runConfigPath, searchPathRoot); return outcome; } finally { try { tempDir.Delete(true); } catch { // Ignore I/O exceptions deleting temporary files. // They will probably be deleted by the OS later on during a file cleanup. } } }
protected override void RunTestsInternal(ITestCommand rootTestCommand, ITestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { using (progressMonitor) { progressMonitor.BeginTask("Verifying Specifications", rootTestCommand.TestCount); if (options.SkipTestExecution) { SkipAll(rootTestCommand, parentTestStep); } else { RunTest(rootTestCommand, parentTestStep, progressMonitor); } } }
/// <inheritdoc /> protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { using (progressMonitor.BeginTask(Resources.ConcordionTestController_RunningConcordionTests, rootTestCommand.TestCount)) { if (progressMonitor.IsCanceled) return new TestResult(TestOutcome.Canceled); if (options.SkipTestExecution) { return SkipAll(rootTestCommand, parentTestStep); } else { return RunTest(rootTestCommand, parentTestStep, progressMonitor); } } }
private static TestResult RunTestFixture(ITestCommand testCommand, ConcordionTest concordionTest, TestStep parentTestStep) { ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep); // The magic happens here! var concordion = new ConcordionBuilder() .WithSource(concordionTest.Source) .WithTarget(concordionTest.Target) .WithSpecificationProcessingListener(new GallioResultRenderer()) .Build(); ConstructorInfo constructor = concordionTest.FixtureType.GetConstructor(Type.EmptyTypes); var fixture=constructor.Invoke(new object[]{}); var summary = concordion.Process(concordionTest.Resource, fixture); bool passed = !(summary.HasFailures || summary.HasExceptions); testContext.AddAssertCount((int)summary.SuccessCount + (int)summary.FailureCount); return testContext.FinishStep(passed ? TestOutcome.Passed : TestOutcome.Failed, null); }
private static TestResult RunTest(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor) { Test test = testCommand.Test; progressMonitor.SetStatus(test.Name); TestResult result; ConcordionTest concordionTest = test as ConcordionTest; if (concordionTest == null) { result = RunChildTests(testCommand, parentTestStep, progressMonitor); } else { result = RunTestFixture(testCommand, concordionTest, parentTestStep); } progressMonitor.Worked(1); return result; }
private TestResult RunAssembly( ITestCommand command, TestStep rootStep ) { ITestContext assemblyContext = command.StartPrimaryChildStep( rootStep ); TestOutcome outcome = TestOutcome.Passed; foreach( ITestCommand contextCommand in command.Children ) { NSpecContextTest contextTest = contextCommand.Test as NSpecContextTest; if( contextTest == null ) continue; var contextResult = this.RunContext( contextTest, contextCommand, assemblyContext.TestStep ); outcome = outcome.CombineWith( contextResult.Outcome ); assemblyContext.SetInterimOutcome( outcome ); } return assemblyContext.FinishStep( outcome, null ); }
private static TestResult RunTest(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor) { Test test = testCommand.Test; progressMonitor.SetStatus(test.Name); TestResult result; XunitTest xunitTest = test as XunitTest; if (xunitTest == null) { result = RunChildTests(testCommand, parentTestStep, progressMonitor); } else { result = RunTestFixture(testCommand, xunitTest.TypeInfo, parentTestStep); } progressMonitor.Worked(1); return result; }
private void RunTest(ITestCommand testCommand, ITestStep parentTestStep, IProgressMonitor progressMonitor) { ITest test = testCommand.Test; progressMonitor.SetStatus(test.Name); MachineSpecificationTest specification = test as MachineSpecificationTest; MachineContextTest description = test as MachineContextTest; if (specification != null) { //RunContextTest(specification, testComman); } else if (description != null) { RunContextTest(description, testCommand, parentTestStep); } else { Debug.WriteLine("Got something weird " + test.GetType().ToString()); } }
public TestHarnessCommand(TestHarnessClassCommandAttribute attribute, ITestCommand inner) : base(inner) { if (!Int32.TryParse(KuduUtils.GetTestSetting(RunsSettingKey), out _runs)) { _runs = attribute.Runs; } _runs = Math.Max(DefaultRuns, _runs); if (!Int32.TryParse(KuduUtils.GetTestSetting(RetriesSettingKey), out _retries)) { _retries = attribute.Retries; } _retries = Math.Max(DefaultRetries, _retries); if (!Boolean.TryParse(KuduUtils.GetTestSetting(SuppressErrorSettingKey), out _suppressError)) { _suppressError = attribute.SuppressError; } }
/// <inheritdoc /> protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { IList<Test> allTheTest = parentTestStep.Test.Children; PopulateSuiteFixtureData(allTheTest, options); using (progressMonitor.BeginTask(Resources.ConcordionTestController_RunningConcordionTests, rootTestCommand.TestCount)) { if (progressMonitor.IsCanceled) { return new TestResult(TestOutcome.Canceled); } if (options.SkipTestExecution) { return SkipAll(rootTestCommand, parentTestStep); } else { return RunTest(rootTestCommand, parentTestStep, progressMonitor); } } }
/// <inheritdoc /> protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { IList<ITestCommand> testCommands = rootTestCommand.GetAllCommands(); using (progressMonitor.BeginTask(Resources.CSUnitTestController_RunningCSUnitTests, testCommands.Count)) { if (progressMonitor.IsCanceled) { return new TestResult(TestOutcome.Canceled); } if (options.SkipTestExecution) { return SkipAll(rootTestCommand, parentTestStep); } using (RunnerMonitor monitor = new RunnerMonitor(testCommands, parentTestStep, progressMonitor)) { return monitor.Run(assemblyLocation); } } }
private MethodResult Execute(ITestCommand inner) { if (! _tasks.Any()) { foreach (var testCommand in _innerCommands) { var command = (DelegatingTestCommand) testCommand; Func<MethodResult> action = () => { var innerCommand = (IMethodInfo) _methodInfoField.GetValue(command.InnerCommand); return new LifetimeCommand(command, innerCommand).Execute(null); }; var task = new Task<MethodResult>(action, TaskCreationOptions.LongRunning); _tasks.Add(testCommand, task); } StartAllTasks(_tasks.Values); } try { return _tasks[inner].Result; } catch (AggregateException e) { if (e.InnerExceptions.Count == 1) { //This looks better in nunit ExceptionUtility.RethrowWithNoStackTraceLoss(e.InnerException); throw; } else { throw; } } }
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); } } }
private static async Task StartProcessingLoop(IClusterClient client) { while (true) { WriteTestPrompt(); string input = Console.ReadLine(); if (string.IsNullOrWhiteSpace(input)) { continue; } input = input.ToLower(); if (input == "cls") { Console.Clear(); continue; } if (input == "?") { Console.WriteLine("==> Available Test Classes"); foreach (string className in Runner.GetTestClassNames()) { Console.WriteLine(" ==> " + className); } continue; } if (input == "exit") { break; } ITestCommand command = Runner.Parse(input); await RunTest(client, command); } }
/// <inheritdoc /> protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor) { ThrowIfDisposed(); IList<ITestCommand> testCommands = rootTestCommand.GetAllCommands(); using (progressMonitor.BeginTask(Resources.NUnitTestController_RunningNUnitTests, testCommands.Count)) { if (progressMonitor.IsCanceled) return new TestResult(TestOutcome.Canceled); if (options.SkipTestExecution) { return SkipAll(rootTestCommand, parentTestStep); } else { using (RunMonitor monitor = new RunMonitor(runner, testCommands, parentTestStep, progressMonitor)) { return monitor.Run(); } } } }
private static bool RunTestCommands(ITestCommand testCommand, XunitTestClassCommand testClassCommand, IEnumerable <XunitTestCommand> xunitTestCommands, TestStep parentTestStep, bool isPrimary) { bool passed = true; foreach (XunitTestCommand xunitTestCommand in xunitTestCommands) { TestStep testStep = new TestStep(testCommand.Test, parentTestStep, testCommand.Test.Name, testCommand.Test.CodeElement, isPrimary); testStep.IsDynamic = !isPrimary; string displayName = xunitTestCommand.DisplayName; if (displayName != null) { testStep.Name = StripTypeNamePrefixFromDisplayName(testCommand.Test.CodeElement, displayName); } ITestContext testContext = testCommand.StartStep(testStep); passed &= RunTestCommandAndFinishStep(testContext, testClassCommand, xunitTestCommand); } return(passed); }
private void SyntaxCheck(ITestCommand command, string target, string value) { if (null == command) { throw new ArgumentNullException("command"); } if (command.Syntax.HasFlag(TestCommandSyntax.Target)) { if (string.IsNullOrWhiteSpace(target)) { throw new InvalidOperationException(Properties.Resources.TestCommand_Validate_RequireTarget); } } if (command.Syntax.HasFlag(TestCommandSyntax.Value)) { if (string.IsNullOrWhiteSpace(value)) { throw new InvalidOperationException(Properties.Resources.TestCommand_Validate_RequireValue); } } }
private TestResult RunTest(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor) { Test test = testCommand.Test; progressMonitor.SetStatus(test.Name); // The first test should be an assembly test MSTestAssembly assemblyTest = testCommand.Test as MSTestAssembly; TestOutcome outcome; TestResult result; if (assemblyTest != null) { ITestContext assemblyContext = testCommand.StartPrimaryChildStep(parentTestStep); try { MSTestRunner runner = MSTestRunner.GetRunnerForFrameworkVersion(frameworkVersion); outcome = runner.RunSession(assemblyContext, assemblyTest, testCommand, parentTestStep, progressMonitor); } catch (Exception ex) { assemblyContext.LogWriter.Failures.WriteException(ex, "Internal Error"); outcome = TestOutcome.Error; } result = assemblyContext.FinishStep(outcome, null); } else { result = new TestResult(TestOutcome.Skipped); } progressMonitor.Worked(1); return(result); }
private static bool RunTestMethod(ITestCommand testCommand, MethodInfo methodInfo, XunitTestClassCommand testClassCommand, TestStep parentTestStep) { List <XunitTestCommand> xunitTestCommands; try { xunitTestCommands = new List <XunitTestCommand>(XunitTestCommandFactory.Make(testClassCommand, XunitReflector.Wrap(methodInfo))); } catch (Exception ex) { // Xunit can throw exceptions when making commands if the test is malformed. ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep); testContext.LogWriter.Failures.WriteException(ex, "Internal Error"); testContext.FinishStep(TestOutcome.Failed, null); return(false); } if (xunitTestCommands.Count == 0) { return(true); } if (xunitTestCommands.Count == 1) { return(RunTestCommands(testCommand, testClassCommand, xunitTestCommands, parentTestStep, true)); } // Introduce a common primary test step for theories. ITestContext primaryTestContext = testCommand.StartPrimaryChildStep(parentTestStep); bool result = RunTestCommands(testCommand, testClassCommand, xunitTestCommands, primaryTestContext.TestStep, false); primaryTestContext.FinishStep(result ? TestOutcome.Passed : TestOutcome.Failed, null); return(result); }
public RunTestAction CreateActionToRunTest(ITestCommand testCommand, Model.Tree.TestStep parentTestStep, Sandbox parentSandbox, PatternTestActionsDecorator testActionsDecorator) { return(new RunTestAction(this, testCommand, parentTestStep, parentSandbox, testActionsDecorator)); }
public RunTestInstanceAction(PatternTestExecutor executor, ITestCommand testCommand) { this.executor = executor; this.testCommand = testCommand; }
/// <param name="innerCommand">The <see cref="ITestCommand"/> to wrap</param> /// <param name="method">The method being used as a test</param> public IocLifetimeCommand(ITestCommand innerCommand, IMethodInfo method) : base(method, MethodUtility.GetDisplayName(method), MethodUtility.GetTimeoutParameter(method)) { _innerCommand = innerCommand; }
public ParallelDelegateTestCommand(ITestCommand inner, IMethodInfo method, int count) : base(method, inner.DisplayName, inner.Timeout) { _inner = inner; _count = count; }
public ActionTestCommandWrapper(ITestCommand inner, Action <object> action) { this.inner = inner; this.action = action; }
/// <summary> /// Implementation of <see cref="Run" /> called after argument validation has taken place. /// </summary> /// <param name="rootTestCommand">The root test command, not null.</param> /// <param name="parentTestStep">The parent test step, or null if none.</param> /// <param name="options">The test execution options, not null.</param> /// <param name="progressMonitor">The progress monitor, not null.</param> /// <returns>The combined result of the root test command.</returns> protected internal abstract TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor);
public CustomSkipCommand(IMethodInfo method, ITestCommand innerCommand) : base(innerCommand) { this.method = method; }
public ExceptionInterceptingCommand(ITestCommand wrappedCommand, IMethodInfo method) : base(wrappedCommand) { this.method = method; }
public MTAThreadTimeoutCommand(ITestCommand innerComand, IMethodInfo testMethod) : base(innerComand) { _testMethod = testMethod; }
/// <summary> /// Creates a new instance of the <see cref="TimeoutCommand"/> class. /// </summary> /// <param name="innerCommand">The command to be run</param> /// <param name="timeout">The timout, in milliseconds</param> /// <param name="testMethod">The method under test</param> public TimeoutCommand(ITestCommand innerCommand, int timeout, IMethodInfo testMethod) : base(innerCommand) { this.timeout = timeout; this.testMethod = testMethod; }
private void BuildCommands(FilterSet <ITestDescriptor> filterSet, bool exactFilter) { var testCommandFactory = new DefaultTestCommandFactory(); rootCommand = testCommandFactory.BuildCommands(model, filterSet, exactFilter, Mocks.Stub <ITestContextManager>()); }
public PartialTrustCommand(ITestCommand command, IDictionary <MethodInfo, object> fixtures = null) { _command = command; _fixtures = fixtures; }
public InjectedTestCommand(ITestCommand testCommand, ITestFixtureFactory testFixtureFactory) { _testCommand = testCommand; _testFixtureFactory = testFixtureFactory; }
public ObservationCommand(ITestCommand innerCommand, IMethodInfo methodInfo) { _innerCommand = innerCommand; _methodInfo = methodInfo; }
public RunTestAction(PatternTestExecutor executor, ITestCommand testCommand, TestContext parentContext, PatternTestActionsDecorator testActionsDecorator) : this(executor, testCommand, parentContext.TestStep, parentContext.Sandbox, testActionsDecorator) { this.parentContext = parentContext; }
/// <inheritdoc /> sealed protected override void RunAssembly(Assembly assembly, TestExplorationOptions testExplorationOptions, TestExecutionOptions testExecutionOptions, IMessageSink messageSink, IProgressMonitor progressMonitor) { using (progressMonitor.BeginTask(string.Format("Running {0} tests.", FrameworkName), 100)) { using (TestHarness testHarness = CreateTestHarness()) { IDisposable appDomainState = null; try { progressMonitor.SetStatus("Setting up the test harness."); appDomainState = testHarness.SetUpAppDomain(); progressMonitor.Worked(1); progressMonitor.SetStatus("Building the test model."); TestModel testModel = GenerateTestModel(assembly, messageSink); progressMonitor.Worked(3); progressMonitor.SetStatus("Building the test commands."); ITestContextManager testContextManager = CreateTestContextManager(messageSink); ITestCommand rootTestCommand = GenerateCommandTree(testModel, testExecutionOptions, testContextManager); progressMonitor.Worked(2); progressMonitor.SetStatus("Running the tests."); if (rootTestCommand != null) { RunTestCommandsAction action = new RunTestCommandsAction(this, rootTestCommand, testExecutionOptions, testHarness, testContextManager, progressMonitor.CreateSubProgressMonitor(93)); if (testExecutionOptions.SingleThreaded) { // The execution options require the use of a single thread. action.Run(); } else { // Create a new thread so that we can consistently set the default apartment // state to STA and so as to reduce the effective stack depth during the // test run. We use Thread instead of ThreadTask because we do not // require the ability to abort the Thread so we do not need to take the // extra overhead. Thread thread = new Thread(action.Run); thread.Name = "Simple Test Driver"; thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } if (action.Exception != null) { throw new ModelException("A fatal exception occurred while running test commands.", action.Exception); } } else { progressMonitor.Worked(93); } } finally { progressMonitor.SetStatus("Tearing down the test harness."); if (appDomainState != null) { appDomainState.Dispose(); } progressMonitor.Worked(1); } } } }
/// <summary> /// Initializes a new instance of the <see cref="SpecificationCommand"/> class. /// </summary> /// <param name="innerCommand">The inner command.</param> /// <param name="testMethod">The test method.</param> public SpecificationCommand(ITestCommand innerCommand, IMethodInfo testMethod) : base(testMethod, testMethod.Name, 0) { _innerCommand = innerCommand; }
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)); }
/// <summary> /// Creates a new instance of the <see cref="DelegatingTestCommand"/> class. /// </summary> /// <param name="innerCommand">The inner command to delegate to.</param> protected DelegatingTestCommand(ITestCommand innerCommand) { this.innerCommand = innerCommand; }
public TestHarnessCommand(TestHarnessClassCommandAttribute attribute, ITestCommand inner, IMethodInfo testMethod) : base(inner) { _testMethod = testMethod; // prefer imperative over config settings if (attribute.Runs != DefaultRuns || !Int32.TryParse(KuduUtils.GetTestSetting(RunsSettingKey), out _runs)) { _runs = attribute.Runs; } _runs = Math.Max(DefaultRuns, _runs); if (attribute.Retries != DefaultRetries || !Int32.TryParse(KuduUtils.GetTestSetting(RetriesSettingKey), out _retries)) { _retries = attribute.Retries; } _retries = Math.Max(DefaultRetries, _retries); if (attribute.SuppressError != DefaultSuppressError || !Boolean.TryParse(KuduUtils.GetTestSetting(SuppressErrorSettingKey), out _suppressError)) { _suppressError = attribute.SuppressError; } }
/// <summary> /// Creates a new instance of the <see cref="TimedCommand"/> class. /// </summary> /// <param name="innerCommand">The command that will be timed.</param> public TimedCommand(ITestCommand innerCommand) : base(innerCommand) { }
private SkippableTestCommand(IMethodInfo method, ITestCommand inner) { this.method = method; this.inner = inner; }
public CancellingCommand(ITestCommand innerCommand, TheoryWithLimitedFailuresAttribute owner) : base(innerCommand) { this.owner = owner; }
/// <summary> /// Initializes a new instance of the <see cref="BeforeAfterCommand"/> class. /// </summary> /// <param name="innerCommand">The inner command.</param> /// <param name="testMethod">The method.</param> public BeforeAfterCommand(ITestCommand innerCommand, MethodInfo testMethod) : base(innerCommand) { this.testMethod = testMethod; }