Saturday, October 6, 2018

Java - Cucumber Hello World example

In the previous article we have seen JBehave Hello World example. In this article we will see same Hello World example but with using Cucumber.

Like JBehave, Cucumber is also used for behavior-driven development (BDD) testing. To know more about Cucumber click here.

Below is the eclipse folder structure -

Create a maven project and add the following files


This class contains the hello world business logic that need to be tested using Cucumber

This file contains cucumber test cases

This file contains the steps for BDD testing

This is the main class from where all the cucumber test cases are triggered. Test cases are included in .feature files. You can have one or more .feature files.

Output -

You can also re-write features using Scenario Outlines as shown below.