public async Task RunTestsAsync(IEnumerable <ITest> selectedTests, TestExecutionOptions options, CancellationToken cancellationToken)
        {
            this.cancellationToken = cancellationToken;
            GroupTestsByProject(selectedTests);

            ClearTasks();
            ShowUnitTestsPad();
            ShowOutputPad();

            ResetTestResults();
            saveAllFilesCommand.SaveAllFiles();

            // Run the build, if necessary:
            var projectsToBuild = testsByProject.Keys.Where(p => p.IsBuildNeededBeforeTestRun).Select(p => p.Project).ToList();

            if (projectsToBuild.Count > 0)
            {
                using (cancellationToken.Register(buildService.CancelBuild)) {
                    var buildOptions = new BuildOptions(BuildTarget.Build);
                    buildOptions.BuildDetection = BuildOptions.BuildOnExecute;
                    var buildResults = await buildService.BuildAsync(projectsToBuild, buildOptions);

                    if (buildResults.Result != BuildResultCode.Success)
                    {
                        return;
                    }
                }
            }

            cancellationToken.ThrowIfCancellationRequested();
            using (IProgressMonitor progressMonitor = statusBarService.CreateProgressMonitor(cancellationToken)) {
                int projectsLeftToRun = testsByProject.Count;
                foreach (IGrouping <ITestProject, ITest> g in testsByProject.OrderBy(g => g.Key.DisplayName))
                {
                    currentProjectBeingTested = g.Key;
                    progressMonitor.TaskName  = GetProgressMonitorLabel(currentProjectBeingTested);
                    progressMonitor.Progress  = GetProgress(projectsLeftToRun);
                    using (testProgressMonitor = progressMonitor.CreateSubTask(1.0 / testsByProject.Count)) {
                        using (ITestRunner testRunner = currentProjectBeingTested.CreateTestRunner(options)) {
                            testRunner.TestFinished += testRunner_TestFinished;
                            var writer = new MessageViewCategoryTextWriter(testService.UnitTestMessageView);
                            await testRunner.RunAsync(g, testProgressMonitor, writer, testProgressMonitor.CancellationToken);
                        }
                    }
                    projectsLeftToRun--;
                    progressMonitor.CancellationToken.ThrowIfCancellationRequested();
                }
            }

            ShowErrorList();
        }