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 6, 2019
1 parent 3668366 commit 4fd1fa2
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
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", "~> 13.0"
gem "rspec", "~> 3.2"
gem "rubocop", "0.53.0"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -118,6 +119,7 @@ DEPENDENCIES
benchmark-ips
capybara (~> 3.29)
cucumber (~> 3.1)
minitest
rake (~> 13.0)
rspec (~> 3.2)
rubocop (= 0.53.0)
Expand Down
18 changes: 18 additions & 0 deletions features/minitest_basic.feature
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 4fd1fa2

Please sign in to comment.