Saturday, May 11, 2013

[Ruby] Run multiple MiniTest files in command line without other setup required (Rake, ...)

MiniTest is a great, simple build-in test framework for Ruby. We can use immediately without anymore setup beside installing Ruby. But there's an annoying limitation when starting a project that we can only run one file at a time via command line. Try to execute many files with "ruby *" doesn't help.

Here's the simplest way to run multiple minitest files I can think of
ruby -e "Dir.glob('**/*_spec.rb').each { |f| require File.expand_path(f) }"
Change suffix _spec to _test for test-unit style file.


Ryan Davis said...

`rake` is much simpler.

TAP said...

Hey Ryan,

I rethink again, you're right. Rake is not that hard and a lot cleaner. I would say they are equally hard for starting tiny project as I need to look up for the reference to user it for both cases.

When I was writing this blog, it is the first time I get a chance to play with Minitest. As an RSpec-only user, requiring rake to run the test felt alienate to me.

Thanks for make me reconsider rake again

Clojure how to get JVM options from inside application

(.getInputArguments ( Credit:  How to get vm arguments from inside of java applic...