Closed kcorman closed 5 years ago
I'm not sure it is an issue: by design, TestNG keeps state between tests and you have to clean the context by yourself. But agree, it could be difficult to understand why it is failing.
The test fails due to finishing with the interrupt flag set to true
is definitively my favorite solution.
Fyi, you should be able to have the expected behavior by using a listener that will check the thread flag and mark the test as failed.
@kcorman - As @juherr mentioned, TestNG is not supposed to be aware of the interrupted states because it doesn't set them. You should be able to get this sorted out at your test project level itself by building an IInvokedMethodListener
implementation wherein you do something like this
if (Thread.currentThread().isInterrupted()) {
Thread.interrupted();
}
Closing this issue.
TestNG Version
v6.14.3
Expected behavior
When a test method returns with the current thread interrupt flag set, I would expect one of the following things to happen
Either of the above approaches would be reasonably easy to deal with and understand what's going on
Actual behavior
The interrupt flag stays on the thread running the test, which means if that particular thread executes another test which makes an interruptible call, it will throw an interrupted exception, typically leading to unexpected failures that have nothing to do with the current test.
Is the issue reproductible on runner?
Test case sample