Behavior Driven Development and Bamboo: Visualizing Cucumber scenarios

Behavior Driven Development (BDD) aims to bring together the actors involved in software projects, from the stakeholders to developers, and to document functional requirements in simple and understandable standardized language.

These texts are not only meant to make sure everyone has a common understanding or to serve documentation purposes. They can also be used to test and verify whether the defined software criteria have been met with the help of modern tools.

Gherkin syntax is frequently used for describing software behavior. Scenarios are categorized as "given" (output states, initializations), "when" (signal, import, event, action) or "then" (event, output), as can be seen in the following example.

Cucumber is a frequently-used tool that serves as a link between the written requirement descriptions and a specific software test.

Since BDD scenarios are meant to be executed exactly like unit or integration tests on an integration server (a special visualization of the test results is useful), we want to demonstrate in the following tutorial how Cucumber scenarios can be executed on a Bamboo server and how test results can be visualized.

Installing the Cucumber Report Plugin

The Bamboo extension Cucumber Report Plugin by Hindsight Software is available on the Atlassian Marketplace and is free for Bamboo instances of all sizes. The extension can be easily installed (based on Bamboo version) using the plugin manager or the plugin upload in the Bamboo admin area.

Cucumber scenarios and steps

We will now assume we are developing a feature that allows users to search for books with the application. I've recycled the following snippet from a tutorial in my private blog hasCode.com which shows what a BDD scenario might look like (in English here – Cucumber already supports many languages). (If you are interested, you can find sample source texts there for integrating the Cucumber library into a Java application.)

Feature: Book search
  To allow a customer to find his favourite books quickly, the library must offer multiple ways to search for a book.
 
  Scenario: Search books by publication year
    Given a book with the title 'One good book', written by 'Anonymous', published in 14 March 2013
      And another book with the title 'Some other book', written by 'Tim Tomson', published in 23 August 2014
      And another book with the title 'How to cook a dino', written by 'Fred Flintstone', published in 01 January 2012
    When the customer searches for books published between 2013 and 2014
    Then 2 books should have been found
      And Book 1 should have the title 'Some other book'
      And Book 2 should have the title 'One good book'

We will now proceed and configure the verification of scenarios and criteria on a Bamboo server.

Build plan configuration in Bamboo

First, we create a new build plan in Bamboo and insert a simple Maven task that executes a clean test. Assuming the Cucumber Maven project and the associated scenarios have been configured correctly, we don't have to do anything else.

Konfiguration des Build-Plans: Tests mit Maven ausführen.

Configuration of the Build Plan: execute Tests with Maven

Visualizing the test results

After a successful run, Bamboo displays a clearly arranged list of verified scenarios and steps and includes run time information and test results:

Übersicht der durchlaufenen Szenarien

Overview of run scenarios

From here, we can delve deeper into the details of a single scenario step:

Darstellung von Detailinformationen zu einem Szenario

Detailed information of a scenario

It's that easy to integrate Cucumber scenarios into our CI infrastructure. Tests can be collected and performed efficiently. We get a quick overview of our tests, while the stringent visualization helps us discover errors. Effective and useful!

Your partner for individual software projects

Are you already planning a specific software project? Or are there certain processes at your company that have long given you headaches? Is a system or interface slowing down your employees or customers? Then talk to us about it. We look forward to developing a custom solution with you - with the highest standards of quality and complete cost control. We emphasize expandability, performance, scalability, platform independence, and testability in our work. We create custom high-end software solutions that can later be expanded and modified.

Diesen Beitrag auf Deutsch lesen.

Additional Information

Interview: Advantages of Git within the software development and the possibilities of Stash
Stash in Practice – Protecting Branches Made Easy
Bamboo 5.8: Docker Tasks, better AWS Integration, Java 8 Support

Forget Less and Ensure Quality with didit Checklists for Atlassian Cloud Forget Less and Ensure Quality with didit Checklists for Atlassian Cloud Forget Less and Ensure Quality with didit Checklists for Atlassian Cloud
ATTENTION!
Our blog articles reflect the situation at the time of writing and are not updated. It is therefore possible that the contents are outdated and no longer correspond to the latest developments. We do not accept any liability for this.

Leave a Reply