Пример #1
0
        /// <summary>
        /// Reload the current test on command
        /// </summary>
        public void ReloadTest(RuntimeFramework framework)
        {
            log.Info("Reloading tests for " + Path.GetFileName(TestFileName));
            try
            {
                events.FireTestReloading(TestFileName);

                TestPackage package = MakeTestPackage(loadedTestName);
                if (framework != null)
                {
                    package.Settings["RuntimeFramework"] = framework;
                }

                testRunner.Unload();
                testRunner = TestRunnerFactory.MakeTestRunner(package);

                if (testRunner.Load(package))
                {
                    this.currentFramework = package.Settings.Contains("RuntimeFramework")
                        ? package.Settings["RuntimeFramework"] as RuntimeFramework
                        : RuntimeFramework.CurrentFramework;
                }

                loadedTest    = testRunner.Test;
                reloadPending = false;

                testProject.HasChangesRequiringReload = false;
                events.FireTestReloaded(TestFileName, loadedTest);

                log.Info("Reload complete");
            }
            catch (Exception exception)
            {
                log.Error("Reload failed", exception);
                lastException = exception;
                events.FireTestReloadFailed(TestFileName, exception);
            }
        }
Пример #2
0
            public override bool Load(TestPackage package)
            {
                this.TestRunner = TestRunnerFactory.MakeTestRunner(package);

                return(base.Load(package));
            }
Пример #3
0
        public void LoadTest(string testName)
        {
            log.Info("Loading tests for " + Path.GetFileName(TestFileName));

            long startTime = DateTime.Now.Ticks;

            try
            {
                events.FireTestLoading(TestFileName);

                TestPackage package = MakeTestPackage(testName);
                testRunner = TestRunnerFactory.MakeTestRunner(package);

                bool loaded = testRunner.Load(package);

                loadedTest     = testRunner.Test;
                loadedTestName = testName;
                testResult     = null;
                reloadPending  = false;

                if (Services.UserSettings.GetSetting("Options.TestLoader.ReloadOnChange", true))
                {
                    InstallWatcher( );
                }

                if (loaded)
                {
                    this.currentFramework = package.Settings.Contains("RuntimeFramework")
                        ? package.Settings["RuntimeFramework"] as RuntimeFramework
                        : RuntimeFramework.CurrentFramework;

                    testProject.HasChangesRequiringReload = false;
                    events.FireTestLoaded(TestFileName, loadedTest);
                }
                else
                {
                    lastException = new ApplicationException(string.Format("Unable to find test {0} in assembly", testName));
                    events.FireTestLoadFailed(TestFileName, lastException);
                }
            }
            catch (FileNotFoundException exception)
            {
                log.Error("File not found", exception);
                lastException = exception;

                foreach (string assembly in TestProject.ActiveConfig.Assemblies)
                {
                    if (Path.GetFileNameWithoutExtension(assembly) == exception.FileName &&
                        !PathUtils.SamePathOrUnder(testProject.ActiveConfig.BasePath, assembly))
                    {
                        lastException = new ApplicationException(string.Format("Unable to load {0} because it is not located under the AppBase", exception.FileName), exception);
                        break;
                    }
                }

                events.FireTestLoadFailed(TestFileName, lastException);

                double loadTime = (double)(DateTime.Now.Ticks - startTime) / (double)TimeSpan.TicksPerSecond;
                log.Info("Load completed in {0} seconds", loadTime);
            }
            catch (Exception exception)
            {
                log.Error("Failed to load test", exception);

                lastException = exception;
                events.FireTestLoadFailed(TestFileName, exception);
            }
        }