GoogleTestAdapter.TestAdapter.TestExecutor.Cancel C# (CSharp) Method

Cancel() public method

public Cancel ( ) : void
return void
        public void Cancel()
        {
            lock (this)
            {
                _canceled = true;
                _executor?.Cancel();
                _testEnvironment.LogInfo("Test execution canceled.");
            }
        }

Usage Example

コード例 #1
0
        private void DoRunCancelingTests(bool killProcesses, int lower)
        {
            MockOptions.Setup(o => o.KillProcessesOnCancel).Returns(killProcesses);
            List <Model.TestCase> testCasesToRun = TestDataCreator.GetTestCases("Crashing.LongRunning", "LongRunningTests.Test2");

            testCasesToRun.Should().HaveCount(2);

            var stopwatch = new Stopwatch();
            var executor  = new TestExecutor(TestEnvironment.Logger, TestEnvironment.Options, MockDebuggerAttacher.Object);

            var canceller = new Thread(() =>
            {
                Thread.Sleep(WaitBeforeCancelInMs);
                executor.Cancel();
            });

            canceller.Start();

            stopwatch.Start();
            executor.RunTests(testCasesToRun.Select(tc => tc.ToVsTestCase()), MockRunContext.Object, MockFrameworkHandle.Object);
            stopwatch.Stop();

            canceller.Join();
            stopwatch.ElapsedMilliseconds.Should().BeInRange(lower, lower + OverheadInMs);
        }
All Usage Examples Of GoogleTestAdapter.TestAdapter.TestExecutor::Cancel