GoogleTestAdapter icon indicating copy to clipboard operation
GoogleTestAdapter copied to clipboard

Cancel test does not terminate process

Open appls opened this issue 3 years ago • 3 comments

Hi Christian,

I use GoogleTestAdapter 0.18.0. I set "Terminate process on cancel" to "True". When I do a Debug-Run of my test I can terminate the test execution and this results in termination of the running process as expected. However when I do a "normal" Run of my test and I terminate the test execution the process is not terminated and continues to run in the background while the Test Explorer already shows that the test has been canceled. Is my configuration somehow wrong or do I have the wrong assumption that the process should also terminate on cancel? I took a quick look into the code (GoogleTestAdapter/GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs, l. 75 ff.) but did not find anything suspicious.

Any suggestions are appreciated. Hope to hear from you. Cheers, Tobias

appls avatar Feb 15 '22 22:02 appls

Hi Tobias,

as far as I understand, the process should indeed be killed immediately by invoking Process.Kill(). Couple of things to check:

  • do you get debug out saying that the process has been killed? GTA logs this (or logs an error if it fails), but only in debug mode
  • reading the above docs, I notice that killing is done asynchronously, and GTA does not wait for it to succeed. So even if you get a success message, it might take a bit until the process is indeed killed.
  • Which debugger engine do you use? If I remember correctly, running tests (in contrast to debugging them) should always be done with the .NET process stuff, so this should (if at all) have the opposite effect, but in case you do not get log output at all after canceling your tests, this might be the reason

Summarizing, I have no idea why this would work when debugging, but not running (and would expect it to be the other way, if at all)...

csoltenborn avatar Feb 17 '22 07:02 csoltenborn

I've quickly put together some code to improve logging, and to also wait for the actual termination of the process - please give it a try and let me know what you see when enabling Debug mode... Download the VSIX from here, see code changes here.

csoltenborn avatar Feb 17 '22 12:02 csoltenborn

Hi Christian,

I installed your provided VSIX Version 0.18.0.1475. Please find the attached Test log output. DebugRunAbortLog.txt RunAbortLog.txt

I still observe that the process does not terminate when I start the test as a "normal" run. When I abort a test run in "debug" mode it terminates. Can you please double check my RunSettings to verify that there is no error.

Thank you for your support. Cheers, Tobias

appls avatar Feb 21 '22 15:02 appls