예제 #1
0
        /// <summary>
        /// Execute the tests within the specified test file
        /// </summary>
        /// <param name="vm">Test explorer view model</param>
        /// <param name="fileToRun">Test file to run</param>
        /// <param name="token">Token to cancel tests</param>
        private async Task ExecuteFileTests(TestExplorerToolWindowViewModel vm, TestFileItem fileToRun, CancellationToken token)
        {
            if (token.IsCancellationRequested)
            {
                return;
            }

            // --- Preare this file for testing
            fileToRun.Log("Test file execution started");
            var watch = new Stopwatch();

            watch.Start();
            try
            {
                // --- Iterate through all test sets
                foreach (var setToRun in fileToRun.TestSetsToRun)
                {
                    if (token.IsCancellationRequested)
                    {
                        break;
                    }
                    setToRun.State = TestState.Running;
                    SetTestFileState(fileToRun);
                    await ExecuteSetTestsAsync(vm, setToRun, token);

                    SetTestFileState(fileToRun);
                    vm.UpdateCounters();
                }
            }
            catch (Exception ex)
            {
                HandleException(fileToRun, ex);
            }
            finally
            {
                watch.Stop();

                // --- Mark inconclusive nodes
                fileToRun.TestSetsToRun.ForEach(i =>
                {
                    if (i.State == TestState.NotRun)
                    {
                        SetSubTreeState(i, TestState.Inconclusive);
                    }
                });
                SetTestFileState(fileToRun);

                // --- Report outcome
                vm.UpdateCounters();
                ReportEllapsedTime("Test file", fileToRun, watch);
            }
        }
예제 #2
0
 /// <summary>
 /// Set the state of the test file node according to its test sets' state
 /// </summary>
 /// <param name="fileToRun">Test file node</param>
 private static void SetTestFileState(TestFileItem fileToRun)
 {
     SetTestItemState(fileToRun, fileToRun.TestSetsToRun);
 }