How to run all tests with minitest?

后端 未结 9 2216
-上瘾入骨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:37

    $ rake test ran out of the rails 5.0 box.

    0 讨论(0)
  • 2020-12-02 22:39

    Another way to do this using only Ruby's standard library is with Dir.glob. From within a ruby file, this would look like this:

    require "minitest/autorun"
    
    Dir.glob("**/*Test.rb") { |f| require_relative(f) }
    

    Or from the commandline, you can use this command:

    ruby -I . -e "require 'minitest/autorun'; Dir.glob('**/*Test.rb') { |f| require(f) }"
    

    Dir.glob('**/*Test.rb') recursively searches the current directory for any file which matches *Test.rb, so we simply take all those files and require or require_relative them. From the commandline, require_relative fails, so we use require but first add the current directory to the $LOAD_PATH through -I .

    0 讨论(0)
  • 2020-12-02 22:43

    This can also be done via a Makefile.

    default:
      echo "Dir.glob('./test/*_test.rb').each { |file| require file}" | ruby
    

    running make will run all your tests.

    0 讨论(0)
提交回复
热议问题