Skip to content

Latest commit

 

History

History
220 lines (161 loc) · 4.26 KB

README.md

File metadata and controls

220 lines (161 loc) · 4.26 KB

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

Adding tms links

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

Adding issue links

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

Additional labels can be added using allure_ pattern:

it "some test case", allure_1: "visual_test", allure_2: "core_functionality" do
  # test
end

All other metadata tags are also automatically added as labels:

it "some test case", :visual_test, :core_functionality 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 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