Ejemplo n.º 1
0
        private void StartRun(TestModule testModule)
        {
            var testListener = new TestEventListener(this, testModule);

            var services = TestManager.CreateServices(testModule.Path);

            using (var serviceManager = services.ServiceManager)
            {
                serviceManager.StartServices();
                using (var runner = new MasterTestRunner(services, TestManager.CreatePackage(testModule.Path)))
                {
                    var r  = runner;
                    var sm = serviceManager;

                    var registration = state.Cancellation.Token.Register(() =>
                    {
                        r.StopRun(true);
                        sm.StopServices();
                        r.Dispose();
                        sm.Dispose();
                        foreach (var testCase in testModule.TestCaseMap.Values.Where(x => x.Status == TestCaseStatus.Running))
                        {
                            testCase.Status = TestCaseStatus.Cancelled;
                        }
                    });

                    using (registration)
                    {
                        runner.Run(testListener, testModule.Filter);
                        SendMessage(new FinishMessage(testModule));
                        serviceManager.StopServices();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void MissingFileTest(string filename, string message)
        {
            var fullname = Path.Combine(TestContext.CurrentContext.TestDirectory, filename);

            var services = new ServiceContext();

            services.Add(new InProcessTestRunnerFactory());
            services.Add(new ExtensionService());
            services.Add(new DriverService());
#if NET35
            services.Add(new RuntimeFrameworkService());
#endif

            var package = new TestPackage(fullname);
            package.AddSetting("ProcessModel", "InProcess");
            package.AddSetting("DomainUsage", "None");

            var runner = new MasterTestRunner(services, package);

            var result   = runner.Run(this, TestFilter.Empty);
            var sb       = new StringBuilder();
            var writer   = new ExtendedTextWrapper(new StringWriter(sb));
            var reporter = new ResultReporter(result, writer, new ConsoleOptions());

            reporter.WriteErrorsFailuresAndWarningsReport();
            var report = sb.ToString();

            Assert.That(report, Contains.Substring($"1) Invalid : {fullname}"));
            Assert.That(report, Contains.Substring(message));
        }
Ejemplo n.º 3
0
        public void Run()
        {
            _runner.Load(); // Make sure it's pre-loaded so we get count in start-run
            var result = _runner.Run(this, TestFilter.Empty);

            CheckTestRunResult(result);
        }
        public void SetUp()
        {
            var assemblyPath = GetLocalPath(AssemblyName);

            var serviceContext = new ServiceContext();

            serviceContext.Add(new DriverService());
            serviceContext.Add(new InProcessTestRunnerFactory());
            serviceContext.Add(new ExtensionService());
            serviceContext.Add(new FakeRuntimeService());
#if NETFRAMEWORK
            serviceContext.Add(new DomainManager());
#endif

            var runner = new MasterTestRunner(serviceContext, new TestPackage(assemblyPath));
            runner.Load();
            _engineResult = runner.Run(null, TestFilter.Empty);
        }