---
title: "Testing using Cucumber in Ruby/JRuby"
canonical: "https://docs.getxray.app/space/XRAY/301477951/Testing%20using%20Cucumber%20in%20Ruby%2FJRuby"
format: markdown
---
# Overview

In this tutorial, we will create some tests in Cucumber for Ruby (or JRuby).

The test (specification) is initially created in Jira as a Cucumber Test and afterwards, it is exported using the UI or the REST API.

# Requirements

- Install Ruby or JRuby
- Install the "cucumber" gem

# Description


After creating a Cucumber Test, of Cucumber Type "Scenario Outline", in Jira, you can export the specification of the test to a Cucumber .feature file via the REST API or the **Export to Cucumber** UI action from within the Test Execution issue.

The created file will be similar to the following: 


##### **1_CALC-889.feature**

```
@REQ_CALC-889
Feature: As a user, I can calculate the sum of 2 numbers
	
	@TEST_CALC-908 @UI @core
	Scenario Outline: Cucumber Test As a user, I can calculate the sum of 2 numbers
							Given I have entered <input_1> into the calculator
							And I have entered <input_2> into the calculator
							When I press <button>
							Then the result should be <output> on the screen
							 
				
						
							  Examples:
							    | input_1 | input_2 | button | output |
							    | 20      | 30      | add    | 50     |
							    | 2       | 5       | add    | 7      |
							    | 0       | 40      | add    | 40     | 
							    | 4       | 50      | add    | 54     | 


```



After running the tests and generating the Cucumber JSON  report (e.g., ), it can be imported to Xray via the REST API or the **Import Execution Results** action within the Test Execution.

```
cucumber -x -f json -o data.json
```

> ℹ️ **Please note**
> ℹ️ 
> ℹ️ As the report format in Cucumber JSON is being deprecated in favour of [Cucumber Messages](https://github.com/cucumber/cucumber/tree/master/json-formatter), a protocol buffer based implementation, the previous command needs to be adapted slightly.
> ℹ️ 
> ℹ️ The report starts by being generated in Cucumber Messages, using "-f message" argument, and then converted to the legacy Cucumber JSON report using the tool [cucumber-json-formatter](https://github.com/cucumber/cucumber/tree/master/json-formatter).
> ℹ️ 
> ℹ️ 
> ℹ️ ```shell
> ℹ️ cucumber -x -f message -o data.ndjson
> ℹ️ cat data.ndjson | cucumber-json-formatter --format ndjson > data.json
> ℹ️ ```


The execution screen details will not only provide information on the test run result, but also of each of the examples provided in the Scenario Outline.


> ℹ️ The Cucumber Scenarios Example/Result details (i.e., **Hooks, Backgrounds **and** Steps**) are only available for executions done in Xray v2.2.0 and above.


 


> ℹ️ The icon> Macro (inline-media-image)
> ℹ️ 
> ℹ️  represents the evidences ("embeddings") for each **Hook, Background **and** Steps**, but is only available for executions done in Xray v2.3.0 and above.

> ℹ️ **Learn more**
> ℹ️ 
> ℹ️ Please see [Testing in BDD with Gherkin based frameworks (e.g. Cucumber)](https://getxraydocs.atlassian.net/wiki/spaces/XRAY/pages/301470422) for an overview on how to use Cucumber Tests with Xray.


# References

- [https://cucumber.io/docs/reference/ruby](https://cucumber.io/docs/reference/ruby)
- [Automated Tests (Import/Export)](https://getxraydocs.atlassian.net/wiki/spaces/XRAY/pages/301404124)
- [Exporting Cucumber Tests - REST](https://getxraydocs.atlassian.net/wiki/spaces/XRAY/pages/301667739)