The AssemblyRunner class executes tests in a single assembly
        /// <summary>
        /// Called by the Visual Studio IDE to run all tests. Also called by TFS Build
        /// to run either all or selected tests. In the latter case, a filter is provided
        /// as part of the run context.
        /// </summary>
        /// <param name="sources">Sources to be run.</param>
        /// <param name="runContext">Context to use when executing the tests.</param>
        /// <param name="frameworkHandle">Test log to send results and messages through</param>
        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            testLog.Initialize(frameworkHandle);
            Info("executing tests", "started");

            try
            {
                // Ensure any channels registered by other adapters are unregistered
                CleanUpRegisteredChannels();

                var tfsfilter = new TFSTestFilter(runContext);
                testLog.SendDebugMessage("Keepalive:" + runContext.KeepAlive);
                if (!tfsfilter.HasTfsFilterValue && runContext.KeepAlive)
                    frameworkHandle.EnableShutdownAfterTestRun = true;

                foreach (var source in sources)
                {
                    using (currentRunner = new AssemblyRunner(testLog, source, tfsfilter))
                    {
                        currentRunner.RunAssembly(frameworkHandle);
                    }

                    currentRunner = null;
                }
            }
            catch (Exception ex)
            {
                testLog.SendErrorMessage("Exception " + ex);
            }
            finally
            {
                Info("executing tests", "finished");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Called by the VisualStudio IDE when selected tests are to be run. Never called from TFS Build.
        /// </summary>
        /// <param name="tests">The tests to be run</param>
        /// <param name="runContext">The RunContext</param>
        /// <param name="frameworkHandle">The FrameworkHandle</param>
        public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
#if LAUNCHDEBUGGER
            Debugger.Launch();
#endif

            TestLog.Initialize(frameworkHandle);
            if (RegistryFailure)
            {
                TestLog.SendErrorMessage(ErrorMsg);
            }
            var enableShutdown = (UseVsKeepEngineRunning) ? !runContext.KeepAlive : true;
            frameworkHandle.EnableShutdownAfterTestRun = enableShutdown;
            Debug("executing tests", "EnableShutdown set to " + enableShutdown);
            Info("executing tests", "started");

            // Ensure any channels registered by other adapters are unregistered
            CleanUpRegisteredChannels();

            var assemblyGroups = tests.GroupBy(tc => tc.Source);
            foreach (var assemblyGroup in assemblyGroups)
            {
                currentRunner = new AssemblyRunner(TestLog, assemblyGroup.Key, assemblyGroup, this);
                currentRunner.RunAssembly(frameworkHandle);
            }

            Info("executing tests", "finished");
        }
Esempio n. 3
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (currentRunner != null)
         {
             currentRunner.Dispose();
         }
     }
     currentRunner = null;
 }
Esempio n. 4
0
        /// <summary>
        /// Called by the Visual Studio IDE to run all tests. Also called by TFS Build
        /// to run either all or selected tests. In the latter case, a filter is provided
        /// as part of the run context.
        /// </summary>
        /// <param name="sources">Sources to be run.</param>
        /// <param name="runContext">Context to use when executing the tests.</param>
        /// <param name="frameworkHandle">Test log to send results and messages through</param>
        public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            TestLog.Initialize(frameworkHandle);
            if (RegistryFailure)
            {
                TestLog.SendErrorMessage(ErrorMsg);
            }
            Info("executing tests", "started");

            try
            {
                // Ensure any channels registered by other adapters are unregistered
                CleanUpRegisteredChannels();

                var tfsfilter = new TfsTestFilter(runContext);
                TestLog.SendDebugMessage("Keepalive:" + runContext.KeepAlive);
                var enableShutdown = (UseVsKeepEngineRunning) ? !runContext.KeepAlive : true;
                if (!tfsfilter.HasTfsFilterValue)
                {
                    if (!(enableShutdown && !runContext.KeepAlive))  // Otherwise causes exception when run as commandline, illegal to enableshutdown when Keepalive is false, might be only VS2012
                    {
                        frameworkHandle.EnableShutdownAfterTestRun = enableShutdown;
                    }
                }

                foreach (var source in sources)
                {
                    string sourceAssembly = source;

                    if (!Path.IsPathRooted(sourceAssembly))
                    {
                        sourceAssembly = Path.Combine(Environment.CurrentDirectory, sourceAssembly);
                    }
                    using (currentRunner = new AssemblyRunner(TestLog, sourceAssembly, tfsfilter, this))
                    {
                        currentRunner.RunAssembly(frameworkHandle);
                    }

                    currentRunner = null;
                }
            }
            catch (Exception ex)
            {
                TestLog.SendErrorMessage("Exception thrown executing tests", ex);
            }
            finally
            {
                Info("executing tests", "finished");
            }
        }
        /// <summary>
        /// Called by the Visual Studio IDE to run all tests. Also called by TFS Build
        /// to run either all or selected tests. In the latter case, a filter is provided
        /// as part of the run context.
        /// </summary>
        /// <param name="sources">Sources to be run.</param>
        /// <param name="runContext">Context to use when executing the tests.</param>
        /// <param name="frameworkHandle">Test log to send results and messages through</param>
        public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            TestLog.Initialize(frameworkHandle);
            if (RegistryFailure)
            {
                TestLog.SendErrorMessage(ErrorMsg);
            }
            Info("executing tests", "started");

            try
            {
                // Ensure any channels registered by other adapters are unregistered
                CleanUpRegisteredChannels();

                var tfsfilter = new TfsTestFilter(runContext);
                TestLog.SendDebugMessage("Keepalive:" + runContext.KeepAlive);
                var enableShutdown = (UseVsKeepEngineRunning) ? !runContext.KeepAlive : true;
                if (!tfsfilter.HasTfsFilterValue)
                {
                    if (!(enableShutdown && !runContext.KeepAlive))  // Otherwise causes exception when run as commandline, illegal to enableshutdown when Keepalive is false, might be only VS2012
                        frameworkHandle.EnableShutdownAfterTestRun = enableShutdown;
                }
                
                foreach (var source in sources)
                {
                    string sourceAssembly = source;

                    if (!Path.IsPathRooted(sourceAssembly))
                    {
                        sourceAssembly = Path.Combine(Environment.CurrentDirectory, sourceAssembly);
                    }
                    using (currentRunner = new AssemblyRunner(TestLog, sourceAssembly, tfsfilter,this))
                    {
                        currentRunner.RunAssembly(frameworkHandle);
                    }

                    currentRunner = null;
                }
            }
            catch (Exception ex)
            {
                TestLog.SendErrorMessage("Exception thrown executing tests", ex);
            }
            finally
            {
                Info("executing tests", "finished");
            }

        }
Esempio n. 6
0
        /// <summary>
        /// Called by the Visual Studio IDE to run all tests. Also called by TFS Build
        /// to run either all or selected tests. In the latter case, a filter is provided
        /// as part of the run context.
        /// </summary>
        /// <param name="sources">Sources to be run.</param>
        /// <param name="runContext">Context to use when executing the tests.</param>
        /// <param name="frameworkHandle">Test log to send results and messages through</param>
        public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            TestLog.Initialize(frameworkHandle);
            if (RegistryFailure)
            {
                TestLog.SendErrorMessage(ErrorMsg);
            }
            Info("executing tests", "started");

            try
            {
                // Ensure any channels registered by other adapters are unregistered
                CleanUpRegisteredChannels();

                var tfsfilter = new TfsTestFilter(runContext);
                TestLog.SendDebugMessage("Keepalive:" + runContext.KeepAlive);
                var enableShutdown = (UseVsKeepEngineRunning) ? !runContext.KeepAlive : true;
                if (!tfsfilter.HasTfsFilterValue)
                {
                    frameworkHandle.EnableShutdownAfterTestRun = enableShutdown;
                }

                foreach (var source in sources)
                {
                    using (currentRunner = new AssemblyRunner(TestLog, source, tfsfilter))
                    {
                        currentRunner.RunAssembly(frameworkHandle);
                    }

                    currentRunner = null;
                }
            }
            catch (Exception ex)
            {
                TestLog.SendErrorMessage("Exception thrown executing tests", ex);
            }
            finally
            {
                Info("executing tests", "finished");
            }
        }
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (currentRunner != null)
         {
             currentRunner.Dispose();
         }
     }
     currentRunner = null;
 }
        /// <summary>
        /// Called by the VisualStudio IDE when selected tests are to be run. Never called from TFS Build.
        /// </summary>
        /// <param name="tests">The tests to be run</param>
        /// <param name="runContext">The RunContext</param>
        /// <param name="frameworkHandle">The FrameworkHandle</param>
        public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            #if LAUNCHDEBUGGER
            Debugger.Launch();
            #endif

            TestLog.Initialize(frameworkHandle);
            if (RegistryFailure)
            {
                TestLog.SendErrorMessage(ErrorMsg);
            }
            var enableShutdown = (UseVsKeepEngineRunning) ? !runContext.KeepAlive : true;
            frameworkHandle.EnableShutdownAfterTestRun = enableShutdown;
            Debug("executing tests", "EnableShutdown set to " +enableShutdown);
            Info("executing tests", "started");

            // Ensure any channels registered by other adapters are unregistered
            CleanUpRegisteredChannels();

            var assemblyGroups = tests.GroupBy(tc => tc.Source);
            foreach (var assemblyGroup in assemblyGroups)
            {
                using (currentRunner = new AssemblyRunner(TestLog, assemblyGroup.Key, assemblyGroup))
                {
                    currentRunner.RunAssembly(frameworkHandle);
                }

                currentRunner = null;
            }

            Info("executing tests", "finished");
        }
        /// <summary>
        /// Called by the VisualStudio IDE when selected tests are to be run. Never called from TFS Build.
        /// </summary>
        /// <param name="tests">The tests to be run</param>
        /// <param name="runContext">The RunContext</param>
        /// <param name="frameworkHandle">The FrameworkHandle</param>
        public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            #if LAUNCHDEBUGGER
            Debugger.Launch();
            #endif

            testLog.Initialize(frameworkHandle);
            if (runContext.KeepAlive)
                frameworkHandle.EnableShutdownAfterTestRun = true;
            Info("executing tests", "started");

            // Ensure any channels registered by other adapters are unregistered
            CleanUpRegisteredChannels();

            var assemblyGroups = tests.GroupBy(tc => tc.Source);
            foreach (var assemblyGroup in assemblyGroups)
            {
                using (currentRunner = new AssemblyRunner(testLog, assemblyGroup.Key, assemblyGroup))
                {
                    currentRunner.RunAssembly(frameworkHandle);
                }

                currentRunner = null;
            }

            Info("executing tests", "finished");
        }