-
-
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
[Java] Add BeforeAll and AfterAll hooks #1876
Conversation
Work in progress to fix #515. TODO: - [ ] How to deal with failure? - [ ] Test with JUnit4 - [ ] Test with JUnit5 - [ ] Test with TestNG - [ ] Test with CLI - [ ] Invoke around semantics? - [ ] How to report execution results? - [ ] TeamCity Plugin - [ ] Pretty formatter - [ ] Messages/Events
To avoid conflicting with JUnit annotations it might be a good idea use names that are relatively unique. For example |
Is there any tentative timeline on it and will it work equally good with parallel executions as well? |
This is an opensource project so there are no promises, timetables or guarantees. It will be done when it is done. It will work as expected with parallel execution within one instance of Cucumber. Because a static context is used for the before hooks different runners (e.g. from the So effectively it will be the same as using JUnits 4 |
@mpkorstanje Just confirming . So the crux is it won't work in forked mode or multi jvm? |
No. As I said, it will work as expected with parallel execution within one instance of Cucumber. For other situations you're dependent on the implementation of your hooks. |
Codecov Report
@@ Coverage Diff @@
## v7.x.x #1876 +/- ##
============================================
+ Coverage 83.27% 83.35% +0.08%
- Complexity 2313 2340 +27
============================================
Files 298 299 +1
Lines 8256 8374 +118
Branches 750 762 +12
============================================
+ Hits 6875 6980 +105
- Misses 1084 1096 +12
- Partials 297 298 +1 Continue to review full report at Codecov.
|
b91f148
to
01e9ca4
Compare
Hello! I am trying to use @BeforeAll but it doesn't work for me..nothing happens, it seems that this method is never used.
DO you have any ideea what I can do? |
To report a bug you'll want to start a new issue. Commenting on old ones just hides the discussion from view. If you do report a bug make sure you have a minimal reproducer. So remove all the parts that are not essential to reproducing the problem. You can read more about that here: https://stackoverflow.com/help/how-to-ask Also if you do report a bug, make sure you have the right open source project. You are using Serenity, not Cucumber. 😉 |
Summary
BeforeAll
andAfterAll
hooks are executed before all scenarios are executed andafter all scenarios have been executed. A hook is declared by annotating a method.
This methods must be static and do not take any arguments.
Hooks are global, all hooks declared in any step definition class will be
executed. The order in which hooks are executed is not defined. An explicit
order can be provided by using the
order
property in the annotation.Notes:
version
3.0.0-M5
or later.all and after all hooks do not fail a test run.
Fixes: #515.
Types of changes
Checklist: