Ruby Minitest and Simplecov starter

  1. Add these gems to your Gemfile:
# frozen_string_literal: true

group :development, :test do
  gem 'minitest'
  gem 'rake'
  gem 'simplecov'
end
  1. Run bundle install to install them.

  2. Create a test/test_helper.rb file containing:

# frozen_string_literal: true

require 'simplecov'
SimpleCov.start do
  enable_coverage :branch
end

$LOAD_PATH.unshift File.expand_path('../lib', __dir__)

require 'minitest/autorun'
  1. Add the following lines to your Rakefile:
# frozen_string_literal: true

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
  t.libs << 'test'
  t.libs << 'lib'
  t.test_files = FileList['test/**/*_test.rb']
end
  1. Create a sample test at test/unit/trial_test.rb to try it out:
# frozen_string_literal: true

require 'test_helper'

describe 'trial' do
  it 'is worthy' do
    assert(true)
  end
end
  1. Run the tests with bundle exec rake test

  2. Learn to use the tools:

Name Link
Minitest https://github.com/seattlerb/minitest
Rake https://github.com/ruby/rake
Simplecov https://github.com/simplecov-ruby/simplecov