Spread the love

Cucumber for test automation

These cucumber tutorials will help you understand about cucumber framework and its installation step by step. It also covers concepts of BDD,Gherkin, Glue.

If you’re on this page, it means you are damn interested in learning cucumber framework for testing.

You can use cucumber for UI automation and also for API test automation. That means, cucumber provides starting point and after that it is up to you , what you want to do next : either you can run Selenium tests or api tests using Rest-assured.

That is awesome!! Let’s dive in to these cucumber tutorials.

How to learn Cucumber framework?

You can learn cucumber step by step:

  1. Cucumber
  2. BDD
  3. Gherkin
  4. Features file
  5. Runner
  6. Glue
  7. Cucumber options
  8. Working on a Project using Cucumber

What is Cucumber?

Cucumber is a software tool which supports BDD (Behavior driven development) . Using cucumber, you can write automated tests .

What is BDD? – Cucumber Tutorials

The full form of BDD is Behaviour-Driven Development.

When it comes to development , it has to be software. So if anybody , asks you , what is BDD ? you can say , it is a software development process. The software products are made under some guidelines and processes . Therefore, we can use BDD to build softwares.

There is always a GAP between Business people ( BA ) and technical people (developers,QA). As a result of this gap, there is always loss and brings many issues in the built software product.

Let me explain further, Business people , they understand plain English language and technical people they speak in terms of programming language like Java,python etc. Now , you can understand why there is a gap.

So we need something which can fill this gap and to fill this we have , BDD.

Read more about BDD here.

We can use gherkin syntax to express our self in plain English.

Cucumber is built to support BDD.

What is Gherkin ? – Cucumber Tutorials

Like in plain English language , you can use a lot of words in sentences to express yourself. But in Gherkin , you have limited words which you can use. These are called as Keywords. Therefore, you can use these Gherkin keywords only and you have to write software requirements / automated tests using Gherkin keywords only.

Feature: Login Functionality

  Scenario: Valid login
    Given the user is on login page of the application
    When the user enters correct username and password
    Then the login successful message appears

Above is written using Gherkin keywords like Given, When , Then .

After Given , rest of the sentence is called Step. For example , “the user is on login page of the application” is one step.

The primary Gherkin keywords are:

  • Feature
  • Rule (as of Gherkin 6)
    Example (or Scenario)
  • Given, When, Then, And, But for steps (or *)
    Background
  • Scenario Outline (or Scenario Template)
  • Examples

Learn how to install Cucumber?

Cucumber-JVM is published in the central Maven repository. You can install it by adding dependencies to your project.

Using Maven :

You will need to add below snippet into your pom.xml .

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java8</artifactId>
    <version>5.6.0</version>
    <scope>test</scope>
</dependency>

Using Gradle :

You will need to add below snippet into your build.gradle file.

dependencies {
    testImplementation 'io.cucumber:cucumber-java8:5.6.0'
    testImplementation 'io.cucumber:cucumber-junit:5.6.0'
}

repositories {
    mavenCentral()
}

Note : If you want next part of this tutorial and interested to learn cucumber in more detail , please comment .