Thursday, March 02, 2006
Execute all Test::Unit tests in a directory
PickAxe gives an example of how to create test suites in Ruby. It's been awhile since I read it, but if I remember correctly it involves simply adding a
When developing a Ruby application I generally put all my tests in a
require 'test_name' for each test you want to run in your suite. This does work, but it can become a maintenance pain.When developing a Ruby application I generally put all my tests in a
Test folder or in folders that are descendants of Test. When I want to execute all the tests, I simply need to require all files that are in or below Test.require 'find'That's it. All files below
Find.find(File.dirname(__FILE__)) do |path|
Find.prune if path =~ /#{File.expand_path('.')}\/#{__FILE__}$/
require path.reverse.chomp(File.expand_path('.').reverse).chomp('/').reverse.chomp('.rb') if !File.directory?(path)
end
Test will be required and therefore executed.
Comments:
<< Home
We use the following
Dir['**/*_test.rb'].each { |testCase| require testCase }
It is pretty concise. It will require all files in subdirectories. We just end all test files with "_test.rb"
Dir['**/*_test.rb'].each { |testCase| require testCase }
It is pretty concise. It will require all files in subdirectories. We just end all test files with "_test.rb"
Hi jay,
What IDE would you recommend for writing ruby apps/pages please as l have seen a few but nothing that grabs my attention.
What IDE would you recommend for writing ruby apps/pages please as l have seen a few but nothing that grabs my attention.
Hello Michael,
IntelliJ IDEA has many features that are wonderful such as Subversion integration, local history, and JavaScript support. Unfortunately, it does not support Ruby well. However, with a few tricks and a hack I think IntelliJ is your best option.
Post a Comment
IntelliJ IDEA has many features that are wonderful such as Subversion integration, local history, and JavaScript support. Unfortunately, it does not support Ruby well. However, with a few tricks and a hack I think IntelliJ is your best option.
<< Home



