Test (Module)

In: test/unit.rb
test/unit/util/procwrapper.rb
test/unit/util/observable.rb
test/unit/util/backtracefilter.rb
test/unit/ui/tk/testrunner.rb
test/unit/ui/testrunnerutilities.rb
test/unit/ui/testrunnermediator.rb
test/unit/ui/gtk2/testrunner.rb
test/unit/ui/gtk/testrunner.rb
test/unit/ui/fox/testrunner.rb
test/unit/ui/console/testrunner.rb
test/unit/testsuite.rb
test/unit/testresult.rb
test/unit/testcase.rb
test/unit/failure.rb
test/unit/error.rb
test/unit/collector.rb
test/unit/collector/objectspace.rb
test/unit/collector/dir.rb
test/unit/autorunner.rb
test/unit/assertions.rb
test/unit/assertionfailederror.rb
Author:Nathaniel Talbott.
Copyright:Copyright © 2000-2002 Nathaniel Talbott. All rights reserved.
License:Ruby license.

Methods

Attributes

collector  [W] 
filters  [RW] 
output_level  [RW] 
pattern  [RW] 
runner  [W] 
suite  [R] 
to_run  [RW] 

Classes and Modules

Module Test::Unit
  ::Module Test::Unit::Assertions
  ::  ::Class Test::Unit::Assertions::AssertionMessage
  ::  ::  ::Class Test::Unit::Assertions::AssertionMessage::Literal
  ::  ::  ::Class Test::Unit::Assertions::AssertionMessage::Template
  ::Module Test::Unit::Collector
  ::  ::Class Test::Unit::Collector::Dir
  ::  ::Class Test::Unit::Collector::ObjectSpace
  ::Module Test::Unit::UI
  ::  ::Module Test::Unit::UI::Console
  ::  ::  ::Class Test::Unit::UI::Console::TestRunner
  ::  ::Module Test::Unit::UI::Fox
  ::  ::  ::Class Test::Unit::UI::Fox::FaultListItem
  ::  ::  ::Class Test::Unit::UI::Fox::TestRunner
  ::  ::Module Test::Unit::UI::GTK
  ::  ::  ::Class Test::Unit::UI::GTK::EnhancedLabel
  ::  ::  ::Class Test::Unit::UI::GTK::EnhancedProgressBar
  ::  ::  ::Class Test::Unit::UI::GTK::FaultListItem
  ::  ::  ::Class Test::Unit::UI::GTK::TestRunner
  ::  ::Module Test::Unit::UI::GTK2
  ::  ::  ::Class Test::Unit::UI::GTK2::EnhancedLabel
  ::  ::  ::Class Test::Unit::UI::GTK2::FaultList
  ::  ::  ::Class Test::Unit::UI::GTK2::TestRunner
  ::  ::Module Test::Unit::UI::TestRunnerUtilities
  ::  ::Module Test::Unit::UI::Tk
  ::  ::  ::Class Test::Unit::UI::Tk::TestRunner
  ::  ::Class Test::Unit::UI::TestRunnerMediator
  ::Module Test::Unit::Util
  ::  ::Module Test::Unit::Util::BacktraceFilter
  ::  ::Module Test::Unit::Util::Observable
  ::  ::Class Test::Unit::Util::ProcWrapper
  ::Class Test::Unit::AssertionFailedError
  ::Class Test::Unit::AutoRunner
  ::Class Test::Unit::Error
  ::Class Test::Unit::Failure
  ::Class Test::Unit::TestCase
  ::Class Test::Unit::TestResult
  ::Class Test::Unit::TestSuite

Public Class methods

[Source]

# File test/unit/autorunner.rb, line 67
      def initialize(standalone)
        Unit.run = true
        @standalone = standalone
        @runner = RUNNERS[:console]
        @collector = COLLECTORS[(standalone ? :dir : :objectspace)]
        @filters = []
        @to_run = []
        @output_level = UI::NORMAL
        yield(self) if(block_given?)
      end

Public Instance methods

[Source]

# File test/unit/autorunner.rb, line 176
      def keyword_display(array)
        list = array.collect {|e, *| e.to_s}
        Array === array or list.sort!
        list.collect {|e| e.sub(/^(.)([A-Za-z]+)(?=\w*$)/, '\\1[\\2]')}.join(", ")
      end

[Source]

# File test/unit/autorunner.rb, line 92
      def options
        @options ||= OptionParser.new do |o|
          o.banner = "Test::Unit automatic runner."
          o.banner << "\nUsage: #{$0} [options] [-- untouched arguments]"

          o.on
          o.on('-r', '--runner=RUNNER', RUNNERS,
               "Use the given RUNNER.",
               "(" + keyword_display(RUNNERS) + ")") do |r|
            @runner = r
          end

          if(@standalone)
            o.on('-a', '--add=TORUN', Array,
                 "Add TORUN to the list of things to run;",
                 "can be a file or a directory.") do |a|
              @to_run.concat(a)
            end

            o.on('-p', '--pattern=PATTERN', String,
                 "Match files to collect against PATTERN.") do |e|
              @pattern = Regexp.new(e.sub(%{\A/(.*)/\Z}m, '\\1'))
            end
          end

          o.on('-n', '--name=NAME', String,
               "Runs tests matching NAME.",
               "(patterns may be used).") do |n|
            n = (%{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
            case n
            when Regexp
              @filters << proc{|t| n =~ t.method_name ? true : nil}
            else
              @filters << proc{|t| n == t.method_name ? true : nil}
            end
          end

          o.on('-t', '--testcase=TESTCASE', String,
               "Runs tests in TestCases matching TESTCASE.",
               "(patterns may be used).") do |n|
            n = (%{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
            case n
            when Regexp
              @filters << proc{|t| n =~ t.class.name ? true : nil}
            else
              @filters << proc{|t| n == t.class.name ? true : nil}
            end
          end

          o.on('-v', '--verbose=[LEVEL]', OUTPUT_LEVELS,
               "Set the output level (default is verbose).",
               "(" + keyword_display(OUTPUT_LEVELS) + ")") do |l|
            @output_level = l || UI::VERBOSE
          end

          o.on('--',
               "Stop processing options so that the",
               "remaining options will be passed to the",
               "test."){o.terminate}

          o.on('-h', '--help', 'Display this help.'){puts o; exit}

          o.on_tail
          o.on_tail('Deprecated options:')

          o.on_tail('--console', 'Console runner (use --runner).') do
            warn("Deprecated option (--console).")
            @runner = RUNNERS[:console]
          end

          o.on_tail('--gtk', 'GTK runner (use --runner).') do
            warn("Deprecated option (--gtk).")
            @runner = RUNNERS[:gtk]
          end

          o.on_tail('--fox', 'Fox runner (use --runner).') do
            warn("Deprecated option (--fox).")
            @runner = RUNNERS[:fox]
          end

          o.on_tail
        end
      end

[Source]

# File test/unit/autorunner.rb, line 78
      def process_args(args = ARGV)
        begin
          @to_run.concat options.parse!(args)
        rescue OptionParser::ParseError => e
          puts e
          puts options
          $! = nil
          abort
        else
          @filters << proc{false} unless(@filters.empty?)
        end
        not @to_run.empty?
      end

[Source]

# File test/unit/autorunner.rb, line 182
      def run
        @suite = @collector[self]
        result = @runner[self] or return false
        result.run(@suite, @output_level).passed?
      end

[Validate]