See also: https://semaphoreci.com/community/tutorials/getting-started-with-minitest
We're going to implement a small unicorn class with these requirements:
This will install minitest globally:
gem install minitest
Creating projects dir/files:
mkdir unicorn
cd unicorn
touch unicorn_test.rb
touch unicorn.rb
# configuring minitest:
gem 'minitest', '~> 5.0'
require 'minitest/autorun'
require 'minitest/pride' # colors! :)
# loading the class we want to test
require_relative 'unicorn'
# starting the test suite
class UnicornTest < Minitest::Test
end
To run the test:
ruby unicorn_test.rb
assert_equal(expected, actual, msg = nil)
assert(test, msg = nil)
assert_equal true, test
refute(test, msg = nil)
assert_equal false, test
A test can be skipped with skip
.
Example:
def test_something_else
skip
assert_equal 1, nil - 1
end