Description
Using the attached code, run the Bug.xml file.
EXPECTED: beforeInvocation, afterInvocation should always be on the same thread as the test.
ACTUAL: When you change the timeout in the annotation transformer (IAnnotationTransformer), the before and after Invocation events are on a different thread.
NOTE: In testing, I noticed that if I set the timeout by the @test annotation, it also has the same problem, but I suspect it happening at run time might make this harder to patch, so I left in the more complex case.
Example output:
beforeInvocation ; Expected SAME Thread: 11 - pool-1-thread-1
myExampleTest ; Expected SAME Thread: 12 - TestNGInvoker-myExampleTest()
afterInvocation ; Expected SAME Thread: 11 - pool-1-thread-1
Possible ways to fix this:
- Make the thread the same even if the timeout changes.
- ITestResult or IInvokedMethod include the thread id or Thread object which is stored when the the test method is executed.
For further detail on the discussion of this issue, see https://groups.google.com/forum/#!topic/testng-users/W3lQsykKa3w