Exemplo n.º 1
0
 public RunTestCommandsAction(SimpleTestDriver driver, ITestCommand rootTestCommand, TestExecutionOptions options, TestHarness testHarness, ITestContextManager testContextManager, IProgressMonitor progressMonitor)
 {
     this.driver             = driver;
     this.rootTestCommand    = rootTestCommand;
     this.options            = options;
     this.testHarness        = testHarness;
     this.testContextManager = testContextManager;
     this.progressMonitor    = progressMonitor;
 }
Exemplo n.º 2
0
        /// <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);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public RunTestCommandsAction(SimpleTestDriver driver, ITestCommand rootTestCommand, TestExecutionOptions options, TestHarness testHarness, ITestContextManager testContextManager, IProgressMonitor progressMonitor)
 {
     this.driver = driver;
     this.rootTestCommand = rootTestCommand;
     this.options = options;
     this.testHarness = testHarness;
     this.testContextManager = testContextManager;
     this.progressMonitor = progressMonitor;
 }