Last active
March 1, 2024 08:01
-
-
Save jcasimir/3c687bd5db16a73b4cf3 to your computer and use it in GitHub Desktop.
Running all MiniTest Tests with SimpleCov
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test/coverage/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake/testtask' | |
Rake::TestTask.new do |t| | |
t.pattern = "test/**/*_test.rb" # This expects your tests to be inside a test subfolder | |
end # and end with '_test.rb` | |
# Run all your test files from the terminal with "rake test" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'simplecov' # These two lines must go first | |
SimpleCov.start | |
require 'minitest/autorun' # Sets up minitest | |
# You could require other shared gems here, too |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class YourClass # Nothing special/unusual here | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'test_helper' # require test_helper first | |
require_relative 'your_class' # require whatever class(es) you're testing | |
class YourClassTest < Minitest::Test | |
def test_it_does_stuff # write your tests like normal | |
assert_equal 100, 100 | |
end | |
end |
Thanks for require 'simplecov' # These two lines must go first
OMG THANK YOU
Thank youu
Don't forget to filter out test files themselves:
SimpleCov.start do
add_filter '/test/'
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THANK YOU 💙