Thursday, March 31, 2011

running single rails unit/functional test

As title.

ruby test/functionals/whatevertest.rb doesn't work, that requires me to replace all require 'test_helper' to require File.dirname(__FILE__) + '/../test_helper'. For some reason most of those test templates have such issue, so I rather to see if there is a hack I could get around it.

From stackoverflow
  • On Linux? why not try (cd test && ruby functionals/whatevertest.rb). Note, the parentheses are important as otherwise your current directory will change to the subdirectory. What it does is fork another shell, change to the subdirectory in it, and run the test.

    goodwill : thats a good one. I changed a bit to (cd test && ruby functional/whatsoevertest.rb) so it works properly with the relative directory structure. Makes perfect sense :)
    tvanfosson : Updated with your fix.
  • Try this:

    ruby -Ilib:test test/functionals/whatevertest.rb

    Daemin : I actually run it with: ruby -I test test/functional/whatevertest.rb but it ends up being the same thing.
  • The answer for the title question would be:

    ruby unit/post_test.rb -n selected_test # use to run only one selected test
    

    but for the body of the question tvanfosson gave a good answer.

0 comments:

Post a Comment