Cucumber with Java

Cucumber uses a language called gherkin

gherkin


Behavior Driven Development

BDD

Cucumber

Cucumber

Steps

  1. Add Cucumber dependencies to pom.xml
  2. In test/resources create the feature file. Feature is the behavior which is implementation of user story.
  3. Write the feature file. With details like Feature, Scenario: Given When Then
Feature: FizzBuzz Game play

  Scenario: Play FizzBuzz to get Fizz
    Given Create a FizzBuzz game play
    When I play with number 3
    Then The result is "Fizz"

  Scenario: Play FizzBuzz to get Buzz
    Given Create a FizzBuzz game play
    When I play with number 5
    Then The result is "Buzz"

  Scenario: Play FizzBuzz to get FizzBuzz
    Given Create a FizzBuzz game play
    When I play with number 15
    Then The result is "FizzBuzz"
  1. Create Step definitions. These are steps for each steps written in feature file like given, when, then.
  2. Use IntelliJ feature to create step definition for each steps.
  3. Add logic to each step definition.