There is an event OnStopTest Event, but it states "the test script finishes by the moment the OnStopTest event handler starts, the objects created by the script become invalid."
Here is my use case:
I'm watching my test run and I see something went wrong, so I want to stop it instead of waiting for it to completely timeout or fail every following test item.
However, my test item is built to attempt to clean up even in the event of a failure. Therefore, if I stop the test, I'll have to clean up after that test manually, which can be time consuming. The alternative is to wait and click Stop at just the right moment between test items, but that is difficult because I have to sit and watch it closely. Also, it's easy to miss it and stop it after it started setting up the next test (which leaves me to clean that up manually).
I had an idea: Catch the Stop click event, which OnStopTest does, and ignore the stop until the test item ends at which point I will stop all execution. Using the same logic, I'd be able to stop all execution right away if I click Stop twice.
The downside is OnStopTest is already after the execution is stopped, so there's no continuing the test. My request is to catch when the user clicks Stop before it actually stops.
Let me know if anyone has any other suggestions too. Thanks!