Giter Club home page Giter Club logo

rspec-tap-formatters's Introduction

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:

TAP version 13
# test: String {
  # group: #present? {
    # group: when whitespaces and other characters {
      ok 1 - returns true
      1..1
      # tests: 1, passed: 1
    }
    # group: when nil {
      not ok 1 - returns false
        ---
        location: "./resources/string_spec.rb:8"
        error: |-
          Failure/Error: expect(string.present?).to eq(false)
          NoMethodError:
            undefined method `present?' for nil:NilClass
        backtrace: "./resources/string_spec.rb:9:in `block (4 levels) in <top (required)>'"
        ...
      1..1
      # tests: 1, failed: 1
    }
    # group: when whitespaces only {
      ok 1 - returns false
      1..1
      # tests: 1, passed: 1
    }
    1..3
    # tests: 3, passed: 2, failed: 1
  }
  1..3
  # tests: 3, passed: 2, failed: 1
}
1..3
# tests: 3, passed: 2, failed: 1
# duration: 0.026471 seconds
# seed: 27428

You can check the reports for other formats here.

Installation

Installation is pretty standard:

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:

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

You can also install using the GitHub package registry:

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

Usage

You can specify the format as the command argument:

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

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

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

You can also configure the .rspec file:

# other configurations
--format RSpec::TAP::Formatters::Default
--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

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

rspec-tap-formatters's People

Contributors

avmnu-sng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.