Git Product home page Git Product logo

rspec-flaky's Introduction

Gem Version Gem YARD

RSpecFlaky

The most common reason for test flakiness is randomized factories which fill a database before test execution. This small gem is designed to help you find out what exactly attribute values were assigned to an investigated model during a failed and passed execution.

image

Article about gem: https://blog.rnds.pro/006-rspecflaky (in russian)

Installation

Add this line to test group of your application's Gemfile:

gem 'rspec-flaky'

Install the gem:

bundle

That's all. Select the model whose attributes will be dumped:

it 'is flaky test', tables: [User, Post] do
    expect([true, false]).to be true
end

Usage

Run the command to iteratively run flaky example (option -i specifies the number of iterations):

rspec-flaky path/to/flaky_spec.rb:12 -i 5 

If at least one example is failed gem will generate tables where you are able to investigate source of flakiness by comparing failed and success attribute values. After running your tests, open tmp/flaky_tests/result.html in the browser of your choice. For example, in a Mac Terminal, run the following command from your application's root directory:

open tmp/flaky_tests/result.html

in a debian/ubuntu Terminal,

xdg-open tmp/flaky_tests/result.html

Note: This guide can help if you're unsure which command your particular operating system requires.

It's also possible to dump the whole database per each test example if there was a failed result as well as a passed result. For that just add -d option (currently only PostresQL is available):

rspec-flaky path/to/flaky_speЗc.rb:12 -i 10 -d

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

rspec-flaky's People

Contributors

kinnalru avatar mzsrn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rspec-flaky's Issues

review

  • использовать Tmpdir вместо rm_rf. rm_rf небезопасно - описался в конфиге и снес себе всю папку пользователя
  • dependencies: database_cleaner, rspec
  • тестов нет
  • после первичной эксплуатация я бы поискал повод уйти от процессов к внутренним повторам так, как это делает rspec-retry https://github.com/NoRedInk/rspec-retry/blob/master/lib/rspec/retry.rb

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.