What are Hooks in Cucumber? || JUnit Cucumber Tutorial - Scenario Hooks
Cucumber supports hooks, which are blocks of code that run before or after each scenario. You can define them anywhere in your project or step definition layers, using the methods @Before and @After.
Cucumber Hooks allows us to better manage the code workflow and helps us to reduce the code redundancy. We can say that it is an unseen step, which allows us to perform our scenarios or tests.
Why Cucumber Hooks?
In the world of testing, you must have encountered the situations where you need to perform the prerequisite steps before testing any test scenario.
This prerequisite can be anything from:
Starting a webdriver
Setting up DB connections
Setting up test data
Setting up browser cookies
Navigating to certain page
or anything before the test
In the same way there are always after steps as well of the tests like:
Killing the webdriver
Closing DB connections
Clearing the test data
Clearing browser cookies
Logging out from the application
Printing reports or logs
Taking screenshots on error
or anything after the test
To handle these kind of situations, cucumber hooks are the best choice to use.
Unlike TestNG Annotaions, cucumber supports only two hooks (Before & After) which works at the start and the end of the test scenario. As the name suggests, @before hook gets executed well before any other test scenario, and @after hook gets executed after executing the scenario.
================================================
Full Cucumber BDD Framework Series Playlist: • Cucumber - jvm (BDD Fr...
================================================
Cucumber BDD Framework Code Base GIT URL:
github.com/nav...
Note: Please update the latest Cucumber Dependencies before using Examples feature:
github.com/nav...
====================================================
***Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
www.youtube.co...
***Follow me on my Facebook Page:
/ naveenqtpexpert
Let's join our Automation community for some amazing knowledge sharing and group discussion:
t.me/joinchat/...
~-~~-~~~-~~-~
Follow my Site/Blog: www.naveenautom...
========================================================
Please watch: "Selenium & Automation Interview Preparation - By Naveen AutomationLabs"
• Selenium & Automation ...
~-~~-~~~-~~-~ Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
www.youtube.co...
Follow me on my Facebook Page:
/ naveenqtpexpert
Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
t.me/joinchat/...
Paid courses (Recorded) videos:
Java & Selenium Course: www.naveenautom...
API Course: www.naveenautom... ➡️Get Our Courses✔️
📗 Get My Paid Courses at
Paid courses (Recorded) videos:
Java & Selenium Course: www.naveenautom...
API Course: www.naveenautom...
-------------------------------
✔️SOCIAL NETWORKS
Facebook: / naveenqtpexpert
Twitter: / naveenkhunteta
Blog: www.naveenautom...
--------------------------------
Support My Channel✔️Or Buy Me A Coffee
Paypal: paypal.me/nave...
Google Pay: naveenanimation20@gmail.com
--------------------------------
✔️Thanks for watching!
देखने के लिए धन्यवाद
Благодаря за гледането
感谢您观看
Merci d'avoir regardé
Grazie per la visione
Gracias por ver
شكرا للمشاهدة
19 сен 2024