Quick Start

  • 1. Install

    $ gem install micro_test
    
    
    
    
    
                
  • 2. Write a test

    require 'micro_test'
    class MyTest < MicroTest::Test
      test "some assumption" do
        assert true
      end
    end
                
  • 3. Run tests

    $ mt
    
    
    
    
    
                
  • 4. View output

    
    
    
    
    
    
                

The Interface simple by design


MicroTest::Test Superclass for all tests.
test(desc, &block) Defines a test method.
  • desc - a description of what is being tested
  • &block - a block of code which defines the test
assert(value) Verifies the truthiness of a value.
  • value - the value to assert
before(&block) A callback that runs before each test method.
  • &block - the block of code to execute
after(&block) A callback that runs after each test method.
  • &block - the block of code to execute

See the wiki to troubleshoot or dig into more advanced topics.

Full Example


class MathTest < MicroTest::Test

  before do
    # runs before each test
  end

  test "addition" do
    assert 2 + 2 == 4
  end

  test "subtraction" do
    assert 2 - 2 == 0
  end

  test "multiplication" do
    assert 2 * 2 == 4
  end

  test "division" do
    assert 2 / 2 == 1 # add a trailing comment if you want a message
  end

  # and one failing test
  test "fail" do
    assert 2 + 2 == 5
  end

  after do
    # runs after each test
  end

end

Run Tests


$ mt