Run test scripts from command line

Posted by Zhimin Zhan on November 09, 2009|
Comments



As you may know, test scripts (RWebSpec or Watir) developed by iTest can be run from command line. This has many advantages, You can run tests on machines without iTest installed, integrate with a continuous build server, run specific (or group of) test case, or even generate customized test report.

In iTest v1.6.7, a default Rakefile (default build language in Ruby, a good rake tutorial here) is added when a project is created. To run all tests (*_spec.rb or *_test.rb) in current folder,

rake

For readers who are curious and want to customize the test execution, have a look source of Rakefile below, it is quite simple, isn’t it!

task :default => ["go"]

# List tests you want to exclude
def excluded_test_files
  ["ignore_spec.rb", "bad_test.rb"]
end

desc "run all tests in this folder"
Spec::Rake::SpecTask.new("go") do |t|
  test_files = Dir.glob("*_spec.rb") + Dir.glob("*_test.rb") - excluded_test_files
  t.spec_files = FileList[test_files]
  t.warning = false
end

blog comments powered by Disqus