-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Stream closed exception while trying to finish TestNGCucumberRunner #1917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If I change testng.xml file to run @test methods in serial, the issue / issues from above never happen |
How often is |
Added some logs inside the tearDownClass() method. |
In order to reproduce it easier, you can pull the code from here:
and run it:
|
When a TestNG suite with `parallel="methods"` is executed TestNG will invoke all `@DataProvider` annotated methods. Because these data providers also emit the `TestRunStarted` event this event is emitted twice concurrently. These events collide in the `CanonicalOrderEventPublisher` resulting in a concurrent modification that inserts a null element rather then either of the events. By moving the start of the test execution to the constructor we ensure that test execution is always started serially. Additionally this ensures that it is impossible to emit a `TestRunFinished` event without also emitting a `TestRunStarted` event. This comes at the cost of starting the execution as soon as the `@BeforeClass` method is invoked. This will result in some apparent overhead as `TestNG` is still preparing for execution. Fixes: #1917
Thanks for the reproducer. Though I would have preferred a slightly smaller one. The additional output made it hard add see what was going on. The problem is that while Cucumber can execute scenarios in parallel it can not execute data provider methods in parallel. Because you've set |
When a TestNG suite with `parallel="methods"` is executed TestNG will invoke all `@DataProvider` annotated methods. Because these data providers also emit the `TestRunStarted` event this event is emitted twice concurrently. These events collide in the `CanonicalOrderEventPublisher` resulting in a concurrent modification that inserts a null element rather then either of the events. By moving the start of the test execution to the constructor we ensure that test execution is always started serially. Additionally this ensures that it is impossible to emit a `TestRunFinished` event without also emitting a `TestRunStarted` event. This comes at the cost of starting the execution as soon as the `@BeforeClass` method is invoked. This will result in some apparent overhead as `TestNG` is still preparing for execution. Fixes: #1917
Thanks ! |
When a TestNG suite with `parallel="methods"` is executed TestNG will invoke all `@DataProvider` annotated methods. Because these data providers also emit the `TestRunStarted` event this event is emitted twice concurrently. These events collide in the `CanonicalOrderEventPublisher` resulting in a concurrent modification that inserts a null element rather then either of the events. By moving the start of the test execution to the constructor we ensure that test execution is always started serially. Additionally this ensures that it is impossible to emit a `TestRunFinished` event without also emitting a `TestRunStarted` event. This comes at the cost of starting the execution as soon as the `@BeforeClass` method is invoked. This will result in some apparent overhead as `TestNG` is still preparing for execution. Fixes: #1917
Hi,
I have the a TestNG class for running Cucumber scenarios both serially and in parallel.
It contains two @test methods: one is for running scenarios in parallel and the 2nd is for running scenarios in serial.
Test methods are executed in parallel:
TestNG class:
When all scenarios finish, the @afterclass method is invoked in order to close the TestNGCucumberRunner. Then, the following error is thrown:
But sometimes, when I run the code again, I get a NPE:
This is even stranger, because this is the only stacktrace I get.
Should I create two separate runners in this case, for each test method ?
The code from above is actually taken from the cucumber-testng module:
ScenariosInDifferentGroupsTest
Cheers
The text was updated successfully, but these errors were encountered: