How to run all tests with minitest?

后端 未结 9 2234
-上瘾入骨i
-上瘾入骨i 2020-12-02 21:47

I downloaded source code for a project, found a bug, and fixed it.

Now I want to run tests to find out if I have broken anything.

The Tests are in minitest D

9条回答
  •  时光说笑
    2020-12-02 22:34

    Here is my entire rakefile, which I put in my top directory:

    task :default => :test
    task :test do
      Dir.glob('./test/*_test.rb').each { |file| require file}
    end
    

    To run all my test files at once, I just type rake. That's it!

    Make sure to have require 'minitest/autorun' at the top of each of your Minitest files. Dir.glob definitely DOES work with Minitest.

    To get pretty, colored Minitest output, with names of all my test methods, I have the file minitest_helper.rb in my /test directory. (Had to install the gem minitest-reporters):

    require 'minitest/reporters'
    Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
    require 'minitest/autorun'
    

    I just had to require_relative './minitest_helper' at the top of each of my test files.

提交回复
热议问题