How to run all tests with minitest?

2019-01-13 19: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 DSL.

How do I run them all at once?

I searched for applicable rake tasks etc, but I didn't find any.

标签: ruby minitest
9条回答
Bombasti
2楼-- · 2019-01-13 20:22

locks' answer is better, but I also wanted to point out that you can also run minitest directly from the command like with the ruby command. To run the tests in the spec/calculator_spec.rb file run:

$ ruby spec/calculator_spec.rb 

Remember to include the following code in the calculator_spec.rb file:

require 'minitest/spec'
require 'minitest/autorun'

To run all tests in the spec/ directory, use the following command (see this post for more details Globbing doesn't work with Minitest - Only one file is run)

$ for file in spec/*.rb; do ruby $file; done 
查看更多
虎瘦雄心在
3楼-- · 2019-01-13 20:26

$ rake test ran out of the rails 5.0 box.

查看更多
甜甜的少女心
4楼-- · 2019-01-13 20:27

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.

查看更多
登录 后发表回答