E2E Testing with Cucumber

Ayse Demir
cloudnesil
Published in
2 min readJun 29, 2021

In this article, we will discuss End-to-End (E2E)Testing with Cucumber. I will generally use Javascript in my E2E tests, but there are some questions I would like to go through before I get started.

Why Behaviour Driven Development (BDD) ?

In BDD you can build your test cases structurally but in a natural language. This way all your scenarios can be understood by customers and developers.

Why E2E Testing ?

E2E tests are the best way to check the entire system structure at once. When you start E2E testing, your entire system/application will be tested according to your scenarios. E2E testing enables developers to spot their mistakes and fix them before it’s too late.

Another benefit of E2E testing is that all project members can understand the code and what it does.

Why Cucumber ?

Cucumber is a tool that runs all scenarios in .features files and is also known as the best way to work with BDD. As I mentioned earlier all scenarios are stored in .feature files and cucumber will read scenarios in .feature files. We run our tests on the browser with the help of Protractor, a automation testing framework for Angular and AngularJS applications. Protractor helps us run our E2E test cases in the browser like a real user.

Protractor Configuration

Before we start our E2E tests, we will configure some settings in the configuration file. We’re just adding some Protractor configurations and step definitions. Here is an example showing the config file;

The simple test scenario of logging into a web application and a test definition file used to make a selection from the screen can be seen below;

In summary;

I tried to explain how the Cucumber and E2E tests work with the BDD approach.

Thank you for reading and please comment below and let me know your thoughts.

--

--