Cucumber Testing Tutorial

Cucumber Testing

Introduction of Cucumber Testing

In this topic, we will learn about cucumber testing and its framework, process, functionality, e.tc.

Nowadays, it is very popular among many testers, developers and mostly used in the company that does testing of software. Cucumber is an automation testing framework supporting BDD (Behaviour-driven development).

Before heading toward cucumber testing, we will know about its prerequisite.

Prerequisite:-

  • You should have some basic knowledge of the JAVA programming language.
  • You should have some knowledge of text editors.
  • You should have some basic knowledge of RUBY and JUnit.
  • You should have some experience of testing and knowledge about testing tools.

What is Cucumber?

Introduction of Cucumber Testing:-

 Cucumber is not an automation framework. It is a BDD (Behaviour Driven Development) tool. It is      widely used tool for testing the behaviour of the application/software. It uses Gherkin language for script/test writing.

 Any person can understand its tests whether that person has technical knowledge or not. It uses Ruby as a programming language.

 It’s basic use to implement BDD to remove the communication gap. It works as a bridge between technical and non-technical people .It is an Open tool source for test automation 

Cucumber has an implementation in –Ruby, Jruby, Java, Groovy, Javascript, .NET, e.t.c

Why do we need cucumber?

Most software projects involve people from different teams (Technical and non-technical persons) working together, so high-quality communication is required between them. But when we use a different testing approach like Data-Driven etc., in that case, a non-technical person cannot understand the test cases well. So, we have to use an approach that can be easy to understand by a non-technical person too.

Cucumber using Gherkin language , which is very similar to the English language. Every test scenario is written in Gherkin language, so everyone can easily understand what is happening under a particular test scenario.

Advantages of cucumber –

1. Business People/ Developers / Management can understand what Functionality is being implemented.

2. It is helpful to involve business stakeholders who can’t easily read and understand the code.

3. We can run Features/ Scenarios from RunnerClass with various options.

4. You can use tags to organize and group your scenarios.

5. Quick and easy setup and execution.

6. Style of writing test allows for easier reuse of code in the tests.

7. Using cucumber, the test case written is very easy and understandable.

8. It helps the developer, tester, or any non-technical people to track /understand the progress of the Functionality.

9. Cucumber testing focuses on end-user experience.

Disadvantage of cucumber –

1. Implementation-wise, we will have an additional Feature File in Gherkin language to consider. So, it might consume more time.

2. Reduction in Team work.

Note:

Before proceeding further in cucumber testing tutorial, let us know about Behaviour Driven Development (BDD), Acceptance Test Driven Development (ATDD) and Test Driven Development (TDD):

1. What is BDD (Behaviour Driven Development):-

Introduction of Cucumber Testing:-

It describes the overall Behaviour of the system, how the system behaves, what it does, and what you can do the functionality behind it.

 It is all about the collaboration between teams. i.e., in this process, we have different stakeholders, QA team, Business analysts e. t. c .They collaborate and discuss the business requirement, problems and then accordingly, they convert them into the user's story.

BDD process generates common documentation that all teams and stakeholders can understand, and this documentation serves as a single source of truth for all the teams in the organization. 

2. What is ATDD (Acceptance Test Driven Development):-

Introduction of Cucumber Testing:-

Acceptance tests are the tests form the external point of view. In ATDD whole development team and business stakeholders are involved.

Firstly, it is discussed what is required by the end-user, then the user stories are created with those acceptance criteria .The developer first writes a test for those acceptance criteria . Developer then writes the code to make the test pass .If the test fails, ATDD refactors the code until the test is passed .It is implementation-independent.

Acceptance criteria and tests are defined during story creation .The acceptance criteria help testers to identify the testing period easily.

It helps developers to write accurate unit tests which focus on business needs .ATDD quickly determines if acceptance criteria have been met.   

It is a kind of Behaviour driven development. Because in ATDD, you have to know what tests have to pass for our development to be done, and these are the tests that will describe the system behavior and the system functionality. These tests have to work for the system to be accepted and too determined to be finished.

3. What is TDD (Test-Driven Development):-

Introduction of Cucumber Testing:-

 It is used to make the code simpler, clearer, and bug-free, and it also avoids code duplication. It is a development-centric approach.

 In TDD, we have to prepare a series of test cases, and we do not prepare its functionality.  In this, developers are the main author of the test cases, So before writing the code, we have to write the test cases in this process.

For example If we have a user name that we want to validate, then firstly we create a test case, i.e., this username should not contain any spaces, any special character, should be a valid user name, e.t.c. and then after creating test cases, you will fail them. After that, you will write the code according to it, and in the end, you will have a test that is driving your development effect and a particular function code that can handle all the test cases. In this test, cases are created before the code is written, and if the automated test gets failed, TDD instructs developers to write new code. It is one of the best ways to do the development process.