microtest Build StatusDependency Status

Version 1.2.2

A very tiny testing framework inspired by minitest/minitest.cr.

Features

Installation

Add this to your application's shard.yml:

development_dependencies:
  microtest:
    github: ragmaanir/microtest
    version: ~> 1.2.2

And add this to your spec_helper.rb:

require "microtest"

include Microtest::DSL

Microtest.run!

Usage

describe MyLib::WaterPump do
  test "that it pumps water" do
    p = MyLib::WaterPump.new("main")
    p.enable
    p.start

    assert(p.pumps_water?)
  end

  test "that it pumps with a certain speed" do
    p = MyLib::WaterPump.new("main", speed: 100)
    p.enable
    p.start

    assert(p.pump_speed > 50)
  end

  test "this one is pending since it got no body"

  test "only run this focused test", :focus do
  end

  test! "and this one too since it is focused also" do
  end
end

Run the test with:

crystal spec

You can provide the seed to run the tests in the same order:

SEED=123 crystal spec

Power Assert Output

describe AssertionFailure do
  test "assertion failure" do
    a = 5
    b = "aaaaaa"
    assert "a" * a == b
  end
end

Generates:

Assertion Failure

Microtest Test Output (default reporter)

Default

Reporters

Select the used reporters:

Microtest.run!([
  Microtest::DescriptionReporter.new,
  Microtest::ErrorListReporter.new,
  Microtest::SlowTestsReporter.new,
  Microtest::SummaryReporter.new,
] of Microtest::Reporter)
describe First do
  test "success" do
  end

  test "skip this"
end

describe Second do
  def raise_an_error
    raise "Oh, this is wrong"
  end

  test "first failure" do
    a = 5
    b = 7
    assert a == b * 2
  end

  test "error" do
    raise_an_error
  end
end

Progress Reporter

Progress Reporter

Description Reporter

Description Reporter

When focus active

describe Focus do
  test "not focused" do
  end

  test! "focused" do
  end

  test "focused too", :focus do
  end
end

Focus

Development

I am using guardian to run the tests on each change. Also the guardian task uses the computer voice to report build/test failure/success. Run bin/build to run tests and generate README.md from README.md.template and generate the images of the test outputs (using an alpine docker image).

DONE

TODO

Problems