From the course: Cucumber Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Cucumber hooks: Adding hooks
From the course: Cucumber Essential Training
Cucumber hooks: Adding hooks
- [Instructor] Cucumber Hooks. If you have worked with unit testing tools before, you have probably seen setup and teardown methods. That's exactly what Cucumber Hooks use. Cucumber Hooks are classes that contain methods that have special annotations, namely before and after, and those methods execute before or after each scenario. Let's see Cucumber Hooks in action. I'm going to define my hooks class, but before that, let's define a package called hooks. Within the package, I'm going to define a new class, and I'm going to call it RestaurantSystemHooks. My class is created, so let's go ahead and define two methods here. First one, public void BeforeDisplayMessage. And let's define another method here called AfterDisplayMessage. We're going to apply special annotations to these so this will be @Before and I'm going to import the Before from cucumber.api.java and not from JUnit. Let's annotate the second method. Once again, use cucumber.api.java. Let's show a message here, so I'm just…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Cucumber tags: Add a tag4m 50s
-
(Locked)
Cucumber tags: Multiple tags2m 24s
-
(Locked)
Cucumber tags: Maven test with tags1m 39s
-
(Locked)
Background: Add background2m 26s
-
(Locked)
Background: Duplicate item2m 49s
-
(Locked)
Background: Execution flow2m 53s
-
(Locked)
Cucumber hooks: Adding hooks4m 30s
-
(Locked)
Cucumber hooks: Tagged hooks1m 49s
-
(Locked)
Cucumber reports: Generate reports3m 8s
-
(Locked)
Use monochrome and dryRun parameters3m 37s
-
(Locked)
-
-
-
-