Saturday, October 6, 2018

Java - Cucumber Hello World example (Eclipse + Maven + JUnit)

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

pom.xml


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

HelloWorld.java


This file contains cucumber test cases
hello-world.feature


This file contains the steps for BDD testing
HelloWorldSteps.java


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.
RunCucumberTest.java



Output -




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

hello-world.feature


No comments:

Post a Comment