Upgrade to Pro — share decks privately, control downloads, hide ads and more …

m: a better Ruby Test::Unit runner

m: a better Ruby Test::Unit runner

Run tests by line number in Test::Unit, and more!

Presented at WNYRuby on April 11th, 2012.

Nick Quaranto

April 11, 2012
Tweet

More Decks by Nick Quaranto

Other Decks in Programming

Transcript

  1. m
    a better
    test-unit
    runner
    @qrush

    View Slide

  2. i’m @qrush

    View Slide

  3. @
    i live here

    View Slide

  4. c
    i work at 37signals

    View Slide

  5. stands for
    metal
    m

    View Slide

  6. View Slide

  7. runs tests by
    line number
    m

    View Slide

  8. $ 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 wrote:

    View Slide

  9. $ 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
    run one test:

    View Slide

  10. $ 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
    wrong line:

    View Slide

  11. $ 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
    run it all:

    View Slide

  12. some
    facts
    m

    View Slide

  13. works with test-unit,
    rails, mini-test
    1.
    uses rocco for literate
    documentation
    2.
    four months of daily use
    3.

    View Slide

  14. how does it
    work
    m

    View Slide

  15. programming is not magic

    View Slide

  16. figure out where test
    methods are
    1.
    match what line you chose
    with tests we know about
    2.
    run that test!
    3.

    View Slide

  17. __/\\\\____________/\\\\_
    _\/\\\\\\________/\\\\\\_
    _\/\\\//\\\____/\\\//\\\_
    _\/\\\\///\\\/\\\/_\/\\\_
    _\/\\\__\///\\\/___\/\\\_
    _\/\\\____\///_____\/\\\_
    _\/\\\_____________\/\\\_
    _\/\\\_____________\/\\\_
    _\///______________\///__
    gem install m
    http://quaran.to/m
    https://github.com/qrush/m

    View Slide