Git Product home page Git Product logo

m's Introduction

M.RB

Gem Version Code Climate Build Status Coverage Status


m stands for metal, a better test/unit and minitest test runner that can run tests by line number.

INSTALL

Install via:

$ gem install m

If you’re using Bundler, you’ll need to include it in your Gemfile. Toss it into the test group:

group :test do
  gem "m"
end

USAGE

Basically, I was sick of using the -n flag to grab one test to run. Instead, I prefer how RSpec’s test runner allows tests to be run by line number.

Given this file:

$ cat -n test/example_test.rb
 1  require 'test/unit'
 2
 3  class ExampleTest < Test::Unit::TestCase
 4    def test_apple
 5      assert_equal 1, 1
 6    end
 7
 8    def test_banana
 9      assert_equal 1, 1
10    end
11  end

You can run a test by line number, using format m TEST_FILE:LINE_NUMBER_OF_TEST:

$ m test/example_test.rb:4
Run options: -n /test_apple/

# Running tests:

.

Finished tests in 0.000525s, 1904.7619 tests/s, 1904.7619 assertions/s.

1 tests, 1 assertions, 0 failures, 0 errors, 0 skips

Hit the wrong line number? No problem, m helps you out:

$ m test/example_test.rb:2
No tests found on line 2. Valid tests to run:

 test_apple: m test/examples/test_unit_example_test.rb:4
test_banana: m test/examples/test_unit_example_test.rb:8

Want to run the whole test? Just leave off the line number.

$ m test/example_test.rb
Run options:

# Running tests:

..

Finished tests in 0.001293s, 1546.7904 tests/s, 3093.5808 assertions/s.

1 tests, 2 assertions, 0 failures, 0 errors, 0 skips

If you want to run all the tests in a directory as well as its subdirectories, use the -r flag:

$ m -r test/models
"Searching provided directory for tests recursively"
Run options:

..

Finished in 3.459902s, 45.0880 runs/s, 87.5747 assertions/s.

156 tests, 303 assertions, 0 failures, 0 errors, 13 skips

If you need to pass some option down to the actual runner, that is also supported:

$ m test/models -- --seed 1234
Run options: --seed 1234

..

Finished in 3.459902s, 45.0880 runs/s, 87.5747 assertions/s.

156 tests, 303 assertions, 0 failures, 0 errors, 13 skips

Ensure that you use the -- before the options, otherwise you'll get an invalid option error. Also, these extra option should always be the last argument.

SUPPORT

m works with a few Ruby test frameworks:

  • Test::Unit
  • ActiveSupport::TestCase
  • MiniTest::Unit::TestCase
  • Minitest

CONTRIBUTING

Testing

You can run all the tests with:

bundle exec rake tests

You can also run tests selectively. For minitest 4 run:

bundle exec rake test:minitest4

and the ones for minitest 5 with:

bundle exec rake test:minitest5

LICENSE

This gem is MIT licensed, please see LICENSE for more information.

m's People

Contributors

bcardarella avatar blowmage avatar cldwalker avatar davidcpell avatar duggiefresh avatar felixonmars avatar gi avatar greeneca avatar jeremy avatar kirs avatar klevo avatar markbates avatar maxidr avatar metaskills avatar ngauthier avatar olivierlacan avatar olleolleolle avatar qrush avatar ream88 avatar searls avatar soffes avatar steveklabnik avatar teoljungberg avatar tristandunn avatar tsmmark avatar unmanbearpig avatar zamith 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.