Learn what is Cucumber hooks

Alex Petrovski
A free video tutorial from Alex Petrovski
Software engineer in test
4.3 instructor rating • 1 course • 6,529 students

Lecture description

In this lecture we will learn how to execute any code before and after every test scenario.

Learn more from the full course

Mobile Automation: Appium Cucumber for Android&iOS + Jenkins

Automate Android native application using Cucumber, Appium and Ruby + Bonus iOS Setup!

06:07:01 of on-demand video • Updated March 2020

  • Know how to use Appium framework with Android os
  • Know how to automate any Android application using Appium
  • Know how to use Cucumber framework for any testing project including Selenium
  • Know how to work with Android real devices and emulators
  • Know how to use Appium inspector and Uiautomatorviewer to identify elements in application
  • Know how to install all required tools to begin test automation
  • Able to Implement scalable framework using Cucumber and Ruby
  • Know how to use Appium gestures: swipe, scroll, tap
  • Know how to setup Jenkins server
  • Bonus: Setup project for iOS app with basic elements
English [Auto] In this lecture I will show you what as a cucumber hooks how to use it. And why are you doing that. Let's open our project and inside Support folder. We need to create a new file with the name Hooke's but probably it's going to be able to follow. And in cucumber we have a few hooks. And today we will learn what is a before and after. So let's create first is before it'll be them do. And when you hit return is going to create. And so that window and is going to be executed before every test and they don't. For now let's print statement before who is executed. And now let's create after Huq and also lets the opening statement OK. So what we just created hooks before and after and before. As I said earlier is going to be executed before every test. And later and after hook after every tests and they don't why do we need them boules later when we will start learning apelin. So basically we'll punch you in before hook and Q A if needed in order. Also if tests NATO fails we can take a screenshot of the device and this code is also going to be in the hook in your own project. For example if you need to start any other Sarber test score or clean up database or insert some data in a database is going to be in before Hoog or if you need to clean up some stuff after tests. It can be in other hook. So now let's open the terminal and execute our tests by type and cucumber return and we will see that in every test scenario we have before who is executed and last step after who is executed. And you can see it in a few tests in that room. All right. This is a short lecture. What does a cucumber hooks. Let's jump to the next lecture.