Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

allure-rspec

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allure-rspec

  • 2.25.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

allure-rspec

Yard Docs

Allure adapter for rspec testing framework

Installation

Add it to gemfile:

gem "allure-rspec"

Require in spec_helper or any other setup file:

require "allure-rspec"

Configuration

Following configuration options are supported:

AllureRspec.configure do |config|
  config.results_directory = "report/allure-results"
  config.clean_results_directory = true
  config.logging_level = Logger::INFO
  config.logger = Logger.new($stdout, Logger::DEBUG)
  config.environment = "staging"

  # these are used for creating links to bugs or test cases where {} is replaced with keys of relevant items
  config.link_tms_pattern = "http://www.jira.com/browse/{}"
  config.link_issue_pattern = "http://www.jira.com/browse/{}"
  
  # additional metadata
  # environment.properties
  config.environment_properties = {
    custom_attribute: "foo"
  }
  # categories.json
  config.categories = File.new("my_custom_categories.json")
end

Usage

Via commandline arguments, simply add:

--format AllureRspecFormatter

or

Via RSpec configuration:

RSpec.configure do |config|
  config.formatter = AllureRspecFormatter
end

Configure tms link pattern and rspec tag:

AllureRspec.configure do |config|
  config.link_tms_pattern = "http://www.jira.com/browse/{}"
  config.tms_tag = :tms
end

Add tag to rspec test:

it "some test case", tms: "QA-123" do
  # test
end

It's possible to add multiple tms links using tms_ pattern:

it "some test case", tms_1: "QA-123", tms_2: "QA-124" do
  # test
end

Configure issue link pattern:

AllureRspec.configure do |config|
  config.link_issue_pattern = "http://www.jira.com/browse/{}"
  config.issue_tag = :issue
end

Add tag to rspec test:

it "some test case", issue: "QA-123" do
  # test
end

It's possible to add multiple tms links using issue_ pattern:

it "some test case", issue_1: "QA-123", issue_2: "QA-124" do
  # test
end

Adding custom severity and status details

Configure severity tag:

AllureRspec.configure do |config|
  config.severity_tag = :severity
end

Test severity is set to normal by default:

it "some test case", severity: :critical do
  # test
end

Custom status details can be set via muted, known, flaky tags:

it "some test case", flaky: true, muted: false, known: true do
  # test
end

Adding additional labels to allure test case

  • All metadata tags that have no value are added as labels:
it "some test case", :visual_test, :core_functionality do
  # test
end
  • For tags that define value as string or symbol, value is added as label:
it "some test case", test_type: "visual_test", functionality: "core_functionality" do
  # test
end

will add visual_test and core_functionality labels to test case.

  • Tags that have value as false will not be added as labels:
it "some test case", skipped: false do
  # test
end
Skipping certain tags

To skip adding certain tags as labels, following configuration can be added:

AllureRspec.configure do |config|
  config.ignored_tags = [:core_functionality, :generic_metadata_to_ignore]
end

Behavior driven test grouping

Marking tests with tags :epic, :feature, :story, will group tests accordingly in Behavior report tab.
Tag values can also be configured:

AllureRspec.configure do |config|
  config.epic_tag = :epic
  config.feature_tag = :feature
  config.story_tag = :story
end
context "context", feature: "my feature"  do
  it "some test case", story: "user story" do
    # test
  end
end

context "context 2", feature: "my feature" do
it "some test case 2", story: "user story" do
    # test
  end
end

Custom failure exception

Allure report will mark steps and tests as either Failed or Broken based on exception class that was raised. By default, RSpec::Expectations::ExpectationNotMetError exception will mark test as Failed and all other exceptions will mark test as Broken.

Custom failure exception class can be configured:

AllureRspec.configure do |config|
  config.failure_exception = MyCustomFailedException
end

Custom actions

Rspec example object has access to Allure helper methods. It can be used to add or run steps, add attachments, modify test case etc.

it "some test case" do |e|
  e.run_step("my custom step") do
    # some action
  end
  e.add_attachment(name: "attachment", source: "Some string", type: Allure::ContentType::TXT)
end

Steps

Step annotations

Example project

RSpec Example

FAQs

Package last updated on 21 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc