-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Handler for TestRunStarted event gets triggered after all the tests finish in case of parallel execution of tests #2914
Comments
That is intentional. Most plugins can't handle parallel execution. You'll want to use the cucumber-jvm/cucumber-plugin/src/main/java/io/cucumber/plugin/EventListener.java Lines 9 to 15 in 0cdf507
|
Btw, for setup you might want to look at the |
Thank you @mpkorstanje. Works like a charm! sorry that I missed this in the documentation. |
@mpkorstanje, since there is yet no documentation regarding the use of BeforeAll/AfterAll could you, please, advise, how to correctly use it in Kotlin? As I see, internally, there is a check that this method is static, but with Kotlin it seems impossible to make this check pass |
Docs are here: https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-java#beforeall--afterall And for Java to Kotlin interop you'll want to read: https://kotlinlang.org/docs/java-to-kotlin-interop.html#static-methods |
Many thanks! |
I saw @MazurK239 's question and @mpkorstanje 's answer today, concerning the use of It appears Cucumber's method scanning in As a result, I cannot get this to work in Kotlin... Any thoughts? |
@ejbartelds for bugs it's usually better to start a new issue. |
See #2934 @mpkorstanje |
👓 What did you see?
I registered a plugin that catches
TestRunStarted
andTestRunFinished
events to do some set-up / tear-down logic.This plugin extends
EventListener
and overrides methodsetEventPublisher
.When the tests are run sequentially (both via CLI and JUnit runners), the TestRunStarted handler is invoked, then tests are executed, then TestRunFinished handler is invoked, everything is fine
CLI runner executed in IDEA
JUnit runner executed via Gradle
But when I run the tests in parallel, the handler of TestRunStarted gets invoked right after all tests have been executed. Even though the actual event time stored in event object is correct (see the timestamps in log on the screenshots)
CLI runner executed in IDEA
JUnit runner executed via Gradle
In case of CLI runner I specified
--threads 2
in the program args, in case of JUnit runner I specifiedcucumber.execution.parallel.enabled=true
inside the junit-platform.properties file. The threads count doesn't affect anything in the latter case, it is reproduced even with one thread****✅ What did you expect to see?
I expected that during the parallel test execution the
TestRunStarted
handler will be executed once the event happens, before the tests are started. So that I could run some set-up logic inside it. Currently It seems to not be practical📦 Which tool/library version are you using?
org.junit:junit-bom:5.11.0
io.cucumber:cucumber-bom:7.18.1
🔬 How could we reproduce it?
Minimal reproducible example forked from the cucumber-java skeleton: cucumber-java-issue-events
Run feature file via IntelliJ IDEA (CLI runner will be used) or via Gradle
📚 Any additional context?
No response
The text was updated successfully, but these errors were encountered: