Code Monkey home page Code Monkey logo

factory_girl_test_monitor's Introduction

FactoryGirl Test Monitor

Monitors FactoryGirl strategy invocations (e.g. build, create, etc.) per test with ActiveSupport Instrumentation as described in FactoryGirl's getting started doc in order to output the strategy invocations.

Tries to automatically integrate with MiniTest and/or RSpec.

Has a configurable threshold for strategy invocations before printing a warning message.

This may be very helpful if you are getting "SystemStackError: stack level too deep" errors caused by factory_girl factories. Those are not always trivial to track down without having more info about strategy invocations.

Depending on your reporter, etc. might look something like this in your test output:

FactoryGirlTestMonitor.strategy_invocation_max of 199 was exceeded: {:customer=>{:create=>1}, :contact=>{:create=>1}, :project=>{:create=>216}}
...
  SystemStackError:   stack level too deep
  /path/to/activesupport.../lib/active_support/notifications/instrumenter.rb:23

There you can see that the project factory is involved in 216 creates, which was more in this case than the intended number.

Setup

In your ActiveRecord/Rails 3.1+ project, add this to your Gemfile in your test group:

gem 'factory_girl_test_monitor'

Then run:

bundle install

Configuration

By default the max strategy invocations is 199. To reconfigure can do this in an initializer:

FactoryGirlTestMonitor.strategy_invocation_max = 199

Debug

To track down why support is not being added for minitest or rspec:

FactoryGirlTestMonitor.debug = true

License

Copyright (c) 2013 Gary S. Weaver, released under the MIT license.

factory_girl_test_monitor's People

Contributors

garysweaver avatar

Stargazers

 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.