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
[Core] Separate run, dry-run and skip execution modes #2109
Conversation
bf00837
to
b855ba9
Compare
49a12e9
to
7f692f6
Compare
The `TestHelper` is an overly complex way to run tests. Building a runtime and stubbing the step definitions provides a much simpler and more reliable way to test Cucumbers execution. See the `JUnitFormatterTest` for implementation examples.
7f692f6
to
dcbe190
Compare
874a16c
to
e0d5369
Compare
e0d5369
to
3054771
Compare
3054771
to
e0f8213
Compare
caeb1e1
to
16e7a33
Compare
This sounds like nice cleanup! I still think there is room for improvement. The Here is an example. I've modified your example a little since
WDYT @mpkorstanje? |
It would be more accurate to say that a user aborts the scenario. This is a common feature in JUnit and TestNG and Cucumber supports several exceptions. Because Cucumber doesn't have an aborted state these are all converted to the skipped state. While it is nice that we can inform the user that there were multiple problems. The primary reason for skipping all steps after the first non-passing step is that it simplifies interpreting Cucumbers results.
By skipping all steps after the first non-passing step both expectations hold. Additionally this also makes it much easier to integrate with JUnit and TestNG. Both only support one exception per test. Having additional states may make people wonder why JUnit marked the test as skipped but Cucumber reports undefined steps. And in practice, Cucumber reports all undefined steps with the first exception because we collect the One improvement I would consider though is also emitting ambiguous step events. That way we can report all ambiguous and undefined steps in a single exception and we don't have to throw the |
If you think this makes sense it might be good to create a new feature request where we can hash out the details. Otherwise lets talk about it in the regular call. |
Note to self: We can avoid throwing |
AllureCucumber6Jvm correspondingly updated dry-run steps results changed to PASSED due to cucumber behavior change: cucumber/cucumber-jvm#2109
Given a scenario with several steps:
When executing this the outcome of the result is:
This is wrong, because after the first non-passed result all other steps should be skipped. So:
When using executing this scenario with
--dry-run
the result is:And surprisingly enough this is also wrong. While the skipped and pending states can only be detected by executing an implemented step, the undefined step should be marked as undefined and the ambiguous step that follows it should be skipped.
The cause for this confusion lies in the fact that
--dry-run
was implemented using the skip mechanism rather then its own execution mode that is distinct from both a regular run and skip mode. By implementing these as individual execution modes we can avoid this confusion.Implementing this however revealed that our formatters were often being tested with completely undefined scenarios. This does not provide a representative test and allowed #2102 to come into existence. Fixing this was rather complicated, the formatters were being tested with an overly complicated mock implementation. Replacing this mock implementation with stubs made the tests more readable and removed a significant chunk of complexity.
Fixes: #2102