Recently, I've read quite a few articles about Minitest. I really like the idea of a super lightweight test framework. I decided to replace rspec with it in a recent project and have had no luck getting it all to work. My problems are
a) getting named routes in my acceptance/integration tests (rspec and test::unit seem to automatically include them but no go with minitest),
b) and the overall lack of adoption in rails makes me uneasy (everyone seems to be using rspec though it's used more with gems/libraries).
Is it worth using minitest when rspec has the main dominance with testing rails applications?
I did some work last days to make testing Rails with minitest much straightforward. Please look at http://rawonrails.blogspot.com/2012/01/better-way-of-testing-rails-application.html to find more.
The minitest-rails gem makes this easy.
I recently switched an application from Rspec to Minitest & it was well worth it. Tests run much faster, the syntax encourages smarter, leaner code, & somehow I just have more confidence in the suite now (less magic at work).
The improvement extends to integration/acceptance testing, I find Minitest with Capybara much more readable & straightforward than Cucumber (& much less brittle).
Below is a helper file that should be all you need to get unit, functional & integration tests running with Minitest using spec syntax. This was based on a gist by @tenderlove & a lot of reading/experimentation. Notes & caveats below.
Notes
gem 'minitest'
is necessary to get some more advanced Minitest functionality (let
blocks, etc.)describe
blocks in controller tests throw an errorI'm the author of minitest-rails. Things have changed a lot from the time you originally asked this to now. My answer assumes you're using minitest-rails.
Named Routes
If you are using minitest-rails this just works (now). You can use the generators to create these tests, or write them yourself. All the named routes are available in your acceptance/integration tests.
Adoption
I think we will continue to see increased attention on using Minitest with Rails as we get closer to Rails 4.
Worth it?
I think starting with Minitest now is totally worth it. There is tremendous activity going on in Minitest right now. It aligns nicely with the recent focus on fast tests as well. But it really depends on your app and team dynamics.
Coding Ningja's "MiniTest::Spec setup with Capybara in Rails 3.1" helped a lot with integrating Minitest with Rails.
http://code-ningja.posterous.com/73460416