项目作者: avmnu-sng

项目描述 :
TAP Producer for RSpec-3
高级语言: Ruby
项目地址: git://github.com/avmnu-sng/rspec-tap-formatters.git
创建时间: 2019-10-19T11:59:38Z
项目社区:https://github.com/avmnu-sng/rspec-tap-formatters

开源协议:Other

下载


Gem Version
Build Status
Documentation Status
Inline docs
Maintainability
Test Coverage
Gitter

RSpec TAP Formatters

RSpec TAP Formatters produces TAP 13
output with a proper nested display of example groups and includes stats for the total
number of passed, failed, and pending tests per example group.

Why use TAP Formatter

With TAP format, it is easier to view failure reason immediately without waiting
for the failure dumps at the end. Also, TAP is a universal format, so one can:

  • Leverage other tools to parse the output.
  • Mix in different types of tests with consistent output.

Formatters Behavior

RSpec TAP Formatters supports four variants:

  1. RSpec::TAP::Formatters::Default
  2. RSpec::TAP::Formatters::Compact
  3. RSpec::TAP::Formatters::Flat
  4. RSpec::TAP::Formatters::FlatCompact

Each formatter respects the color configuration for the execution and only
prints colored output when enabled. However, writing to a file will never use
colors. When writing the report to a file, each formatter will print progress status
on the standard output:

  • . for passing
  • F for failing
  • * for pending

Sample Report

Sample report for string_spec.rb using
RSpec::TAP::Formatters::Default format:

  1. TAP version 13
  2. # test: String {
  3. # group: #present? {
  4. # group: when whitespaces and other characters {
  5. ok 1 - returns true
  6. 1..1
  7. # tests: 1, passed: 1
  8. }
  9. # group: when nil {
  10. not ok 1 - returns false
  11. ---
  12. location: "./resources/string_spec.rb:8"
  13. error: |-
  14. Failure/Error: expect(string.present?).to eq(false)
  15. NoMethodError:
  16. undefined method `present?' for nil:NilClass
  17. backtrace: "./resources/string_spec.rb:9:in `block (4 levels) in <top (required)>'"
  18. ...
  19. 1..1
  20. # tests: 1, failed: 1
  21. }
  22. # group: when whitespaces only {
  23. ok 1 - returns false
  24. 1..1
  25. # tests: 1, passed: 1
  26. }
  27. 1..3
  28. # tests: 3, passed: 2, failed: 1
  29. }
  30. 1..3
  31. # tests: 3, passed: 2, failed: 1
  32. }
  33. 1..3
  34. # tests: 3, passed: 2, failed: 1
  35. # duration: 0.026471 seconds
  36. # seed: 27428

You can check the reports for other formats here.

Installation

Installation is pretty standard:

  1. gem install rspec-tap-formatters

You can install using bundler also but do not require it in Gemfile.
Make sure to use it as a test dependency:

  1. group :test do
  2. # other gems
  3. gem 'rspec-tap-formatters', '~> 0.1.0', require: false
  4. end

You can also install using the GitHub package registry:

  1. source 'https://rubygems.pkg.github.com/avmnu-sng' do
  2. gem 'rspec-tap-formatters', '~> 0.1.0', require: false
  3. end

Usage

You can specify the format as the command argument:

  1. rspec --format RSpec::TAP::Formatters::Default

To write to file, provide the --out argument:

  1. rspec --format RSpec::TAP::Formatters::Default --out report.tap

You can also configure the .rspec file:

  1. # other configurations
  2. --format RSpec::TAP::Formatters::Default
  3. --out report.tap

Documentation

Read more about TAP specifications and supported formats in the official docs.

Source Code Documentation

Read the source code documentation here.

Compatibility

RSpec TAP Formatters supports MRI 2.3+ and RSpec 3.

Changelog

The changelog is available here.

Copyright (c) 2019 Abhimanyu Singh. See LICENSE.md for
further details.