diff --git a/Gemfile b/Gemfile index 38d3d6e4..3fac3f7c 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,7 @@ group :development do gem "aruba", "~> 0.14" gem "capybara", "~> 3.29" gem "cucumber", "~> 3.1" + gem "minitest" gem "rake", "~> 12.0" gem "rspec", "~> 3.2" gem "rubocop", "0.53.0" diff --git a/Gemfile.lock b/Gemfile.lock index 881f7db5..d21638f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -56,6 +56,7 @@ GEM gherkin (5.1.0) mini_mime (1.0.2) mini_portile2 (2.4.0) + minitest (5.13.0) multi_json (1.14.1) multi_test (0.1.2) nokogiri (1.10.5) @@ -113,6 +114,7 @@ DEPENDENCIES benchmark-ips capybara (~> 3.29) cucumber (~> 3.1) + minitest rake (~> 12.0) rspec (~> 3.2) rubocop (= 0.53.0) diff --git a/features/minitest_basic.feature b/features/minitest_basic.feature new file mode 100644 index 00000000..4df56009 --- /dev/null +++ b/features/minitest_basic.feature @@ -0,0 +1,18 @@ +Feature: + + Scenario: + Given SimpleCov for Minitest is configured with: + """ + require 'simplecov' + SimpleCov.start + """ + + When I open the coverage report generated with `bundle exec rake minitest` + Then I should see the groups: + | name | coverage | files | + | All Files | 80.0% | 1 | + + And I should see the source files: + | name | coverage | + | lib/faked_project/some_class.rb | 80.0 % | + diff --git a/features/step_definitions/simplecov_steps.rb b/features/step_definitions/simplecov_steps.rb index 56c6844a..2a63582a 100644 --- a/features/step_definitions/simplecov_steps.rb +++ b/features/step_definitions/simplecov_steps.rb @@ -12,6 +12,8 @@ "test" when /Cucumber/i "features/support" + when /Minitest/i + "minitest" else raise ArgumentError, "Could not identify test framework #{framework}!" end diff --git a/spec/faked_project/Rakefile b/spec/faked_project/Rakefile index 05f1c57c..0519dc19 100644 --- a/spec/faked_project/Rakefile +++ b/spec/faked_project/Rakefile @@ -6,3 +6,9 @@ Rake::TestTask.new(:test) do |test| test.test_files = FileList["test/**/*_test.rb"].sort test.verbose = true end + +Rake::TestTask.new(:minitest) do |test| + test.libs << "minitest" + test.test_files = FileList["minitest/**/*_test.rb"].sort + test.verbose = true +end diff --git a/spec/faked_project/minitest/some_test.rb b/spec/faked_project/minitest/some_test.rb new file mode 100644 index 00000000..24e2f1a4 --- /dev/null +++ b/spec/faked_project/minitest/some_test.rb @@ -0,0 +1,16 @@ +require "test_helper" +require "faked_project/some_class" + +class SomeTest < Minitest::Test + def setup + @instance = SomeClass.new("foo") + end + + def test_reverse + assert_equal "oof", @instance.reverse + end + + def test_comparison + assert @instance.compare_with("foo") + end +end diff --git a/spec/faked_project/minitest/test_helper.rb b/spec/faked_project/minitest/test_helper.rb new file mode 100644 index 00000000..4b61b495 --- /dev/null +++ b/spec/faked_project/minitest/test_helper.rb @@ -0,0 +1,11 @@ +require "bundler/setup" + +# We're injecting simplecov_config via aruba in cucumber here +# depending on what the test case is... +begin + require File.join(File.dirname(__FILE__), "simplecov_config") +rescue LoadError + $stderr.puts "No SimpleCov config file found!" +end + +require "minitest/autorun"