Q. How do I use ci_reporter in my Test::Unit scripts?

A. Use a ci_reporter gem …
To install the ci_reporter gem on windows:

gem install ci_reporter

If you’re using Test::Unit, ensure the ci/reporter/rake/test_unit_loader.rb file is loaded before the test is run. If you’re using RSpec, you‘ll need to pass the following arguments to the spec command:

 --require GEM_PATH/lib/ci/reporter/rake/rspec_loader
 --format CI::Reporter::RSpec

You may also want to set the output directory as demonstrated by setting the CI_REPORTS environment variable.

require 'test/unit'
require 'ci/reporter/rake/test_unit_loader.rb'
require 'watir'
ENV["CI_REPORTS"] = 'C:/temp/'
Read More

Q. How do I pass command line arguments to Test::Unit?

A. Use the — argument to stop processing Test::Unit specific arguments …
Module Test::Unit has its own command line arguments as specified by the following:

~/just_add_watir $>ruby test_suite.rb --help
Test::Unit automatic runner.
Usage: test/unit/graph_test.rb [options] [-- untouched arguments]
 
    -r, --runner=RUNNER              Use the given RUNNER.
                                     (c[onsole], f[ox], g[tk], g[tk]2, t[k])
    -n, --name=NAME                  Runs tests matching NAME.
                                     (patterns may be used).
    -t, --testcase=TESTCASE          Runs tests in TestCases matching TESTCASE.
                                     (patterns may be used).
    -v, --verbose=[LEVEL]            Set the output level (default is verbose).
                                     (s[ilent], p[rogress], n[ormal], v[erbose])
     --                           Stop processing options so that the
                                     remaining options will be passed to the
                                     test.
    -h, --help                       Display this help.
 
Deprecated options:
        --console                    Console runner (use --runner).
        --gtk                        GTK runner (use --runner).
        --fox                        Fox runner (use --runner).

Example watir:

def test_0021
  # need to call test unit with -- argument
  puts "argument 1 is: ",ARGV[0]
end
Read More