Beispiel #1
0
        public void TestInit()
        {
            this.runContext        = new TestableRunContextTestExecutionTests(() => new TestableTestCaseFilterExpression((p) => true));
            this.frameworkHandle   = new TestableFrameworkHandle();
            this.cancellationToken = new TestRunCancellationToken();

            this.TestExecutionManager = new TestExecutionManager();
        }
Beispiel #2
0
 internal Task Run(IEnumerable <TestCase> tests, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     if (IsRunning)
     {
         throw new InvalidOperationException("Test run already running");
     }
     token = new TestRunCancellationToken();
     if (cancellationToken.CanBeCanceled)
     {
         cancellationToken.Register(() => token.Cancel());
     }
     return(System.Threading.Tasks.Task.Run(() => {
         new TestExecutionManager().RunTests(tests, this, this, token);
         token = null;
     }));
 }
Beispiel #3
0
        public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle, TestRunCancellationToken cancellationToken)
        {
            this.cancellationToken = cancellationToken;

            var discoverySink = new TestCaseDiscoverySink();

            var tests = new List <TestCase>();

            // deploy everything first.
            foreach (var source in sources)
            {
                if (this.cancellationToken.Canceled)
                {
                    break;
                }

                var logger = (IMessageLogger)frameworkHandle;

                // discover the tests
                this.GetUnitTestDiscoverer().DiscoverTestsInSource(source, logger, discoverySink, runContext);
                tests.AddRange(discoverySink.Tests);

                // Clear discoverSinksTests so that it just stores test for one source at one point of time
                discoverySink.Tests.Clear();
            }

            bool isDeploymentDone = PlatformServiceProvider.Instance.TestDeployment.Deploy(tests, runContext, frameworkHandle);

            // Placing this after deployment since we need information post deployment that we pass in as properties.
            this.CacheSessionParameters(runContext, frameworkHandle);

            // Run tests.
            this.ExecuteTests(tests, runContext, frameworkHandle, isDeploymentDone);

            if (!this.HasAnyTestFailed)
            {
                PlatformServiceProvider.Instance.TestDeployment.Cleanup();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Runs the tests.
        /// </summary>
        /// <param name="tests">Tests to be run.</param>
        /// <param name="runContext">Context to use when executing the tests.</param>
        /// <param name="frameworkHandle">Handle to the framework to record results and to do framework operations.</param>
        /// <param name="runCancellationToken">Test run cancellation tokenn</param>
        public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle, TestRunCancellationToken runCancellationToken)
        {
            Debug.Assert(tests != null, "tests");
            Debug.Assert(runContext != null, "runContext");
            Debug.Assert(frameworkHandle != null, "frameworkHandle");
            Debug.Assert(runCancellationToken != null, "runCancellationToken");

            this.cancellationToken = runCancellationToken;

            var isDeploymentDone = PlatformServiceProvider.Instance.TestDeployment.Deploy(tests, runContext, frameworkHandle);

            // Placing this after deployment since we need information post deployment that we pass in as properties.
            this.CacheSessionParameters(runContext, frameworkHandle);

            // Execute the tests
            this.ExecuteTests(tests, runContext, frameworkHandle, isDeploymentDone);

            if (!this.HasAnyTestFailed)
            {
                PlatformServiceProvider.Instance.TestDeployment.Cleanup();
            }
        }