#coding   #ruby

lazy unit testing

March 12, 2006

inspired by lazy-migrations-table-drop i thought this works for collecting unit tests as well. Decide on a pattern for unit test files(t_*.rb for me) and put this code in something like AllTest.rb and it will execute all units test in the current directory.
  
require 'test/unit'

glob = ARGV[0] && "t_*#{ARGV[0]}*.rb" || "t_*.rb"
dir = File.dirname __FILE__
puts "==> running all unit test in: #{dir}"
Dir.glob("#{dir}/#{glob}").each do |file|
    testname = File.basename(file, ".rb")
    puts "== next: #{testname}"
    require testname
end

Technorati Tags: ,

share this: