Skip to content
Allure report logoAllure Report
Main Navigation ModulesDocumentationStart

English

Español

English

Español

Appearance

Sidebar Navigation

Introduction

Install & Upgrade

Install for Windows

Install for macOS

Install for Linux

Install for Node.js

Upgrade Allure

Getting started

How to view a report

Improving readability of your test reports

Improving navigation in your test report

Features

Test steps

Attachments

Test statuses

Sorting and filtering

Defect categories

Visual analytics

Test stability analysis

History and retries

Timeline

Export to CSV

Export metrics

Guides

JUnit 5 parametrization

JUnit 5 & Selenide: screenshots and attachments

JUnit 5 & Selenium: screenshots and attachments

Setting up JUnit 5 with GitHub Actions

Pytest parameterization

Pytest & Selenium: screenshots and attachments

Pytest & Playwright: screenshots and attachments

Pytest & Playwright: videos

Playwright parameterization

How it works

Overview

Test result file

Container file

Categories file

Environment file

Executor file

History files

Integrations

Azure DevOps

Bamboo

GitHub Actions

Jenkins

JetBrains IDEs

TeamCity

Visual Studio Code

Frameworks

Behat

Getting started

Configuration

Reference

Behave

Getting started

Configuration

Reference

Codeception

Getting started

Configuration

Reference

CodeceptJS

Getting started

Configuration

Reference

Cucumber.js

Getting started

Configuration

Reference

Cucumber-JVM

Getting started

Configuration

Reference

Cucumber.rb

Getting started

Configuration

Reference

Cypress

Getting started

Configuration

Reference

Jasmine

Getting started

Configuration

Reference

JBehave

Getting started

Configuration

Reference

Jest

Getting started

Configuration

Reference

JUnit 4

Getting started

Configuration

Reference

JUnit 5

Getting started

Configuration

Reference

Mocha

Getting started

Configuration

Reference

Newman

Getting started

Configuration

Reference

NUnit

Getting started

Configuration

Reference

PHPUnit

Getting started

Configuration

Reference

Playwright

Getting started

Configuration

Reference

pytest

Getting started

Configuration

Reference

Pytest-BDD

Getting started

Configuration

Reference

Reqnroll

Getting started

Configuration

Reference

REST Assured

Getting started

Configuration

Robot Framework

Getting started

Configuration

Reference

RSpec

Getting started

Configuration

Reference

SpecFlow

Getting started

Configuration

Reference

Spock

Getting started

Configuration

Reference

TestNG

Getting started

Configuration

Reference

Vitest

Getting started

Configuration

Reference

WebdriverIO

Getting started

Configuration

Reference

xUnit.net

Getting started

Configuration

Reference

On this page

Getting started with Allure RSpec ​

Allure RSpec gem latest version

Generate beautiful HTML reports using Allure Report and your RSpec tests.

Allure Report RSpec Example

INFO

Check out the example project at github.com/allure-examples/allure-rspec-example to see Allure RSpec in action.

Setting up ​

1. Prepare your project ​

  1. Install the Allure Report command-line tool, if it is not yet installed in your operating system. Note that Allure Report requires Java, see the installation instructions.

  2. Add Allure RSpec to your project's Gemfile. For example:

    ruby
    source 'https://rubygems.org'
    
    gem 'allure-rspec', '~> 2.23.0'
    gem 'rspec', '~> 3.12'
  3. Open a terminal, go to the project directory and install the dependencies from the Gemfile. For example, if you use Bundler:

    bash
    cd /home/user/myproject
    bundle install
  4. In the project's .rspec file, specify AllureRspecFormatter as the formatter for RSpec.

    plain
    --format AllureRspecFormatter

2. Run tests ​

Run your RSpec tests same way as your would run them usually. For example:

bash
bundle exec rspec

This will save necessary data into reports/allure-results or other directory, according to the Configuration. If the directory already exists, the new files will be added to the existing ones, so that a future report will be based on them all.

3. Generate a report ​

Finally, run Allure to convert the test results into an HTML report. This will automatically open your browser to view the report.

bash
allure serve reports/allure-results

If necessary, replace reports/allure-results with the path to the directory specified in the Configuration.

There are some options that can affect how the report is generated. Run allure --help for the full list of options.

Writing tests ​

The Allure RSpec adapter extends the standard reporting features of RSpec by providing additional capabilities for crafting more informative and structured tests. This section highlights key enhancements that can be utilized:

  • Metadata Annotation: Enhance test reports with descriptions, links, and other metadata.
  • Test Organization: Structure your tests into clear hierarchies for better readability and organization organize tests.
  • Step Division: Break down tests into smaller test steps for easier understanding and maintenance.
  • Parametrized Tests: Clearly describe the parameters for parametrized tests to specify different scenarios.
  • Attachments: Automatically capture screenshots and other files during test execution.
  • Test Selection: Use a test plan file to select which tests to run, allowing for flexible test execution.
  • Environment Details: Include comprehensive environment information to accompany the test report.

Adding Metadata ​

Allure allows you to enrich your reports with a variety of metadata. This additional information provides context and details for each test, enhancing the report's usefulness. Refer to the metadata reference section for an exhaustive list of what can be added.

ruby
describe 'Test my website' do
  it 'test authentication', issue: 'AUTH-123' do
    Allure.description_html 'This test attempts to log into the website using a login and a password.'
    Allure.label 'owner', 'John Doe'
    # ...
  end
end

Organize tests ​

As described in Improving navigation in your test report, Allure supports multiple ways to organize tests into hierarchical structures.

To specify a test's location in the behavior-based hierarchy:

ruby
describe 'Test my website' do
  it 'test authentication' do
    Allure.epic 'Web interface'
    Allure.feature 'Essential features'
    Allure.story 'Authentication'
    # ...
  end
end
ruby
describe 'Test my website' do
  it 'test authentication',
     epic: 'Web interface',
     feature: 'Essential features',
     story: 'Authentication' do
    # ...
  end
end

To specify a test's location in the suite-based hierarchy:

ruby
describe 'Test my website' do
  it 'test authentication' do
    Allure.label 'parentSuite' 'Web interface'
    Allure.suite 'Essential features'
    Allure.label 'subSuite', 'Authentication'
    # ...
  end
end

Divide a test into steps ​

Allure RSpec provides three ways of creating steps and sub-steps: “annotated steps”, “block-based steps” and “no-op steps”, see the reference.

ruby
describe 'Test my website' do
  it 'test authentication' do
    Steps.step_1
    Steps.step_2
  end
end

class Steps
  extend AllureStepAnnotation

  step 'Step 1'
  def self.step_1
    step_1_1
    step_1_2
  end

  step 'Step 1.1'
  def self.step_1_1
    # ...
  end

  step 'Step 1.2'
  def self.step_1_2
    # ...
  end

  step 'Step 2'
  def self.step_2
    step_2_1
    step_2_2
  end

  step 'Step 2.1'
  def self.step_2_1
    # ...
  end

  step 'Step 2.2'
  def self.step_2_2
    # ...
  end
end
ruby
describe 'Test my website' do
  it 'test authentication' do
    Allure.run_step 'Step 1' do

      # ...
      Allure.step name: 'Step 1.1', status: :passed

      # ...
      Allure.step name: 'Step 1.2', status: :passed
    end

    Allure.run_step 'Step 2' do

      # ...
      Allure.step name: 'Step 2.1', status: :passed

      # ...
      Allure.step name: 'Step 2.2', status: :passed
    end
  end
end

Describe parametrized tests ​

With Allure RSpec, it is very easy to implement the parametrized tests pattern, i.e. to run the same test logic with different test data. To do so, just write the test inside a loop and use the variable parameters in both its title and its body.

To display a parameter value in the test report, pass it to the Allure.parameter() function.

ruby
describe 'Test my website' do
  auth_data = [
    ['johndoe', 'qwerty'],
    ['[email protected]', 'qwerty'],
  ]
  auth_data.each do |login, password|
    it "Test authentication as '#{login}'" do
      Allure.parameter 'Login', login
      Allure.parameter 'Password', password
      # ...
    end
  end
end

Attach screenshots and other files ​

In Allure reports, you have the ability to attach various types of files, which can greatly enhance the comprehensibility of the report. A common practice is to attach screenshots that capture the state of the user interface at specific moments during test execution.

For detailed instructions on how to implement attachments, refer to the attachments section in the Allure RSpec reference.

ruby
describe 'Test my website' do
  it 'test authentication' do
    # ...
    Allure.add_attachment name: 'Screenshot',
                          source: File.new('/path/to/image.png'),
                          type: Allure::ContentType::PNG
    Allure.add_attachment name: 'Data',
                          source: 'This is the file content.',
                          type: Allure::ContentType::TXT
  end
end

Select tests via a test plan file ​

If the ALLURE_TESTPLAN_PATH environment variable is defined and points to an existing file, RSpec will only run tests listed in this file.

Here's an example of running tests according to a file named testplan.json:

bash
export ALLURE_TESTPLAN_PATH=testplan.json
bundle exec rspec
plain
setx ALLURE_TESTPLAN_PATH "testplan.json"
bundle exec rspec

Environment information ​

For the main page of the report, you can collect various information about the environment in which the tests were executed. To do so, specify the information in the environment_properties configuration parameter.

For example, it is a good idea to use this to remember the OS version and Ruby version. This may help the future reader investigate bugs that are reproducible only in some environments.

Allure Report Environments Widget

ruby
require 'allure-rspec'

AllureRspec.configure do |config|
  config.environment_properties = {
    os_platform: RbConfig::CONFIG['host_os'],
    ruby_version: RUBY_VERSION,
  }
end

Note that if your launch includes multiple RSpec runs (see How it works), Allure RSpec will only save the environment information from the latest run.

Pager
Previous pageReference
Next pageConfiguration
Powered by

Join our newsletter

Allure TestOps
  • Overview
  • Why choose us
  • Cloud
  • Self-hosted
  • Success Stories
Company
  • Documentation
  • Blog
  • About us
  • Contact
  • Events
© 2025 Qameta Software Inc. All rights reserved.