Cucumber Testing Tutorial
on How to Organize
an E2E or Unit Framework

Cucumber is popular with modern Agile teams that practice behavior-driven development. This is due to the use of human-readable syntax for writing test cases, support for many programming languages, and an extensive community. We at decided that integrating this framework with our test management system could be useful for our customers.

Test automation allows modern Agile QA teams to reduce the time required for the testing cycle and, due to this, to perform quality software releases in the shortest possible time. Let’s see how allows you to work with one of the most popular frameworks, Cucumber.

What is Cucumber?

Cucumber is a framework written in Ruby that supports behavior-driven development (BDD), a behavior-based software development methodology. It uses the easily readable English language – Gherkin, to write user requirements.

The advantage of this approach is that Gherkin syntax is understandable to all team members, including specialists without technical knowledge e.g., (PO) Product Owner or (BA)Business Analyst. This meets one of the basic needs of modern Agile teams – technical and business team collaboration during the testing and development of digital solutions.

Automation Testing With Cucumber

The essence of the BDD approach is that test scripts and acceptance tests should be written before coding begins. This allows testing to be done more efficiently than it would have been done at the product release stage.

BDD scenarios in the Cucumber framework involve using the Given When Then structure to write. This sequence helps to describe the system from the point of view of real users.

👀 Let’s consider an example of such a scenario for testing the login functionality of a website:

Feature: Login

  I want to login on a website

    Given I go to '/login'
    And the field 'email' is empty
    And the field 'password' is empty

  Scenario: Error on empty fields
    When I click on 'enter'
    Then field 'email' should be with error
    And field 'password' should be with error

  Scenario: Wrong password
    When I enter incorrect ‘username’ AND ‘password’ values
    And I click on 'enter'
    Then I should see 'E-mail or password is incorrect’

  Scenario: Login successfully
    When I enter correct ‘username’ AND ‘password’ values
    And I click on 'enter'
    Then I am directed to the homepage

Your team can also try implement this approach in your Agile SDLC(Software development lyfe cycle), the benefits of Cucumber for testing and programming will be appreciated by all ones.

Why Do Many QA Teams Choose Cucumber?

We have tried to highlight the key benefits of test automation with Cucumber:

  1. The software requirements are formulated in simple English text format. As we mentioned earlier, Cucumber uses the Gherkin syntax to write test scripts, which is understandable to all team members, including every non-technical user.
  2. Support for multiple programming languages. Unlike many other frameworks that support a single language, the Cucumber tool supports Ruby, Java, JavaScript, Scala, Perl, and other programming languages. This allows you to write code along with Cucumber in your preferred language without worrying about whether or not you can use the framework.
  3. Written code can be reused. All Cucumber feature files contain clearly structured Given When Then test scenarios. This makes it easier to reuse the code, speed up the testing process, and get the finished software product to market.

Sync Cucumber Tests With Manual Testing

We consider the needs of modern Agile teams who choose to work with the BDD framework Cucumber, so we implemented the possibility of integration with automated tests written with Cucumber in our TMS. This integration is based on the Three Amigos approach, meet more detail: What are 3 Amigos in Agile? by following the link to the article on our Blog.

Sync Cucumber Tests With Manual Testing

Synchronization makes BDD tests available to all team members and allows them to work together on the project. See below how it works step by step.

Getting Started Cucumber From Example (ready boilerplate)

Our TMS supports integration with the most popular testing tools, including WebdriverIO, Playwright, Protractor, TestCafe, CodeceptJS, Codeception, and Jira project management system in the next combination with Cucumber:

  • Cucumber
  • Cypress+BDD
  • Playwtight+BDD
  • WebdriverIO+BDD
  • CodeceptJS+BDD
  • Codeception+BDD
  • TestCafe+BDD
  • Java+BDD works through JUnit XML reporter
  • etc.

Our tool is completely flexible, as you may see. This tutorial has all the information you need to work with BDD successfully. Below we will focus on the Cucumber sample. If you use another tool, change the testing tool you need.

#1 Create A New Test Project

Create a new project in TMS in one click if you have ready test automation framework already, like in the picture. You should choose the BDD option for the BDD project logically.

Create A New Test Project

After then import the feature file. To do this, go into the project dashboard and select the Import Project from the Source Code menu item.

Import Project from the Source Code menu item

#2 Generate API Key And Import Autotests

Select the framework and project language. TCMS recognizes your laptop OS and generates a command with API key according to it. You should copy this command and execute it on CMD. This one uploads your Cucumber tests from the source code to test management.

Generate API Key And Import Autotests

End your importing by pressing the Finish button. At the same time, look at the console, how the importer is analyzing code accurately and displaying the number of founded tests in the test framework.

Import project from Source Code

If you enter your project, you will see these tests. You can view their structure by expanding the tree. You may enter your suites and check test cases inside on the bird’s eye.

First BDD project

In addition to importing an existing feature file, you can create a new manual test case. To do this, select the Create Suite menu item, and in the window that opens – Create Test. You can create tests one at a time or use the Bulk function and write all the tests you need at once.

Create Suite menu

If you copy test case from the code editor, as I did, you can auto-format it to bring it a tidy appearance.

In writing manual test cases, users of our TMS are helped by another feature – Intelligent auto-complete steps. After the feature file is synchronized, all existing steps in it are automatically added to the Steps database. This is very convenient because when writing new test cases, they can be reused by selecting them from the open list.

#3 Organize your Cucumber tests in the best way

If you need to structure test cases, you can reorder them or use Bulk Action, which allows you to reorder tests, create new test suites, move test cases to another test suite, or delete certain tests.

With Project Timeline, or Pulse, you can analyze all the changes you have made to your project. You can see what was changed, by which user, and when, and, if necessary, undo the wrong action with the Rollback or Restore to Previous Version button.

#4 How Do I Create A Report In Cucumber Framework?

For Cucumber, as for other frameworks, there is a Reporter, which must be installed in your test project. Just copy and paste this command into your command line.

How Do I Create A Report In Cucumber Framework
After that, you can run a test run.

test run

During the test run, you will have access to a real-time results report. You will see detailed information about what went wrong if any tests failed. Here you can also see the script code, existing attachments, etc.

real-time results report

If you run a manual test, you can also get a report on its results. You have the opportunity to view the status of each test case or to examine all the details: check what failed. You can also filter the results you want.

Thus, test management allows you to control the performance of manual and automated tests in one place.

The TMS provides additional functions for user convenience. One of them is rich Analytics for your Cucumber testing framework:

Analytics for Cucumber testing framework
In-depth analytics, based on detailed reports of test results, are available on the Project level as well as the Global level (implemented to satisfy QA managers’ needs). Thanks to this feature, you can track test coverage and check if the project has flacky tests, slow tests, ever-failing tests, etc.

Running Cucumber Test On CI\CD

You can set up the CI\CD pipeline and run all or individual Cucumber tests. supports seamless integration with popular CI\CD tools: GitHub, GitLab, Jenkins, Bamboo, and CircleCI. This enables continuous testing, real-time reporting, and notifications at every stage of the software testing lifecycle.

One key thing that you must decide is: in which way do you want to manage the Cucumber scenarios? Do you want to use TMS or Advanced Jira Plugin directly? The Jira plugin allows you to do everything you do in the test management system. All actions are synced between them. between It was done in order to involve non-technical specialists in the technical part of the testing process.

Comparison table: Cucumber vs. Playwright vs. TestCafe

Cucumber Playwright TestCafe
Multilingual framework (supports Ruby, Java, JavaScript, Scala, Perl, and other programming languages) Multilingual framework (supports JavaScript, Python, Java, and C#) Supports only Javascript
Supports parallel testing thanks to the TestNG and Maven modules It is possible to run tests in parallel Parallel mode is available for simultaneous test runs
Actively supported Very actively supported over the past few years Actively supported
Ruby-based framework JavaScript-based automation testing tool JavaScript-based framework
Cucumber framework is not a browser automation tool, but you can use Cucumber with Selenium WebDriver, which supports Google Chrome, Internet Explorer, Safari, Opera, Firefox, and such OSs like Windows, Mac, Linux/Unix. Supports over 40 popular software platforms and OS Supports Google Chrome,
Internet Explorer,
Microsoft Edge,
Mozilla Firefox,
Google Chrome mobile,
Safari mobile, and also three OSs: Linux, Windows, and macOS.
Gherkin language is used for writing test cases – plain English text, understandable to all team members If you don’t want to create tests by hand, you can use the Codegen function, which will generate test cases in the programming language of your choice The TestCafe tests are Node.js scripts
Used for end-to-end, integration and unit testing Preferably used for end-to-end automated testing of web apps Mainly used for end-to-end testing

We hope you were able to learn a lot of useful information from this Cucumber tutorial and take advantage of the integration features that are implemented in our TMS. Namely, on How to organize your Cucumber tests and get a reach report and analytics in a simple way.

The content is available also in video format if you convenient reproduce the steps to visualize your tests and get an informative report by watching.

Create first BDD project
Turn your Jira stories into BDD features as well as test cases into BDD scenarious 👇
Follow us