Skip to content

Commit

Permalink
Add feature for testing minitest
Browse files Browse the repository at this point in the history
  • Loading branch information
adam12 committed Dec 1, 2019
1 parent 3568976 commit 77fd1d2
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -113,6 +114,7 @@ DEPENDENCIES
benchmark-ips
capybara (~> 3.29)
cucumber (~> 3.1)
minitest
rake (~> 12.0)
rspec (~> 3.2)
rubocop (= 0.53.0)
Expand Down
18 changes: 18 additions & 0 deletions 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 % |

2 changes: 2 additions & 0 deletions features/step_definitions/simplecov_steps.rb
Expand Up @@ -12,6 +12,8 @@
"test"
when /Cucumber/i
"features/support"
when /Minitest/i
"minitest"
else
raise ArgumentError, "Could not identify test framework #{framework}!"
end
Expand Down
6 changes: 6 additions & 0 deletions spec/faked_project/Rakefile
Expand Up @@ -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
16 changes: 16 additions & 0 deletions 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
11 changes: 11 additions & 0 deletions 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"

0 comments on commit 77fd1d2

Please sign in to comment.