From 4fd1fa2490ecfe4bb4e7413c90abc5f1d63e657e Mon Sep 17 00:00:00 2001 From: Adam Daniels Date: Sun, 1 Dec 2019 03:35:07 +0000 Subject: [PATCH] Add feature for testing minitest --- Gemfile | 1 + Gemfile.lock | 2 ++ features/minitest_basic.feature | 18 ++++++++++++++++++ features/step_definitions/simplecov_steps.rb | 2 ++ spec/faked_project/Rakefile | 6 ++++++ spec/faked_project/minitest/some_test.rb | 16 ++++++++++++++++ spec/faked_project/minitest/test_helper.rb | 11 +++++++++++ 7 files changed, 56 insertions(+) create mode 100644 features/minitest_basic.feature create mode 100644 spec/faked_project/minitest/some_test.rb create mode 100644 spec/faked_project/minitest/test_helper.rb diff --git a/Gemfile b/Gemfile index 221505f6..fe0add87 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", "~> 13.0" gem "rspec", "~> 3.2" gem "rubocop", "0.53.0" diff --git a/Gemfile.lock b/Gemfile.lock index 7d6259ad..a9b720f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,6 +57,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.7) @@ -118,6 +119,7 @@ DEPENDENCIES benchmark-ips capybara (~> 3.29) cucumber (~> 3.1) + minitest rake (~> 13.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..72da5775 --- /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 + warn "No SimpleCov config file found!" +end + +require "minitest/autorun"