lib/test/unit/testsuite.rb in test-unit-2.1.2 vs lib/test/unit/testsuite.rb in test-unit-2.2.0

- old
+ new

@@ -1,9 +1,10 @@ #-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. +# Copyright:: Copyright (c) 2008-2011 Kouhei Sutou. All rights reserved. # License:: Ruby license. require 'test/unit/error' module Test @@ -16,27 +17,34 @@ # have trouble keeping them straight. Think of something that # has a suite method as simply providing a way to get a # meaningful TestSuite instance. class TestSuite attr_reader :name, :tests - + + # Test suite that has higher priority is ran prior to + # test suites that have lower priority. + attr_accessor :priority + STARTED = name + "::STARTED" FINISHED = name + "::FINISHED" # Creates a new TestSuite with the given name. def initialize(name="Unnamed TestSuite", test_case=nil) @name = name @tests = [] @test_case = test_case + @n_tests = 0 + @priority = 0 end # Runs the tests and/or suites contained in this # TestSuite. def run(result, &progress_block) yield(STARTED, name) run_startup(result) - @tests.each do |test| + while test = @tests.shift + @n_tests += test.size test.run(result, &progress_block) end run_shutdown(result) yield(FINISHED, name) end @@ -53,10 +61,10 @@ # Retuns the rolled up number of tests in this suite; # i.e. if the suite contains other suites, it counts the # tests within those suites, not the suites themselves. def size - total_size = 0 + total_size = @n_tests @tests.each { |test| total_size += test.size } total_size end def empty?