class Test::Unit::TestSuite
一组可以被run
的测试集合。
注意:很容易将TestSuite
实例与具有静态 suite 方法的对象混淆;我知道,因为我自己都很难区分它们。可以将具有 suite 方法的对象简单地看作是提供一种获取有意义的TestSuite
实例的方式。
常量
- FINISHED
- FINISHED_OBJECT
- STARTED
- STARTED_OBJECT
属性
elapsed_time[R]
name[R]
priority[RW]
具有较高优先级的Test
套件将在具有较低优先级的测试套件之前运行。
start_time[R]
test_case[R]
tests[R]
公共类方法
new(name="Unnamed TestSuite", test_case=nil) 点击切换源代码
创建一个具有给定名称的新的TestSuite
。
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 34 def initialize(name="Unnamed TestSuite", test_case=nil) @name = name @tests = [] @test_case = test_case @priority = 0 @start_time = nil @elapsed_time = nil end
公共实例方法
<<(test) 点击切换源代码
将测试添加到套件中。
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 64 def <<(test) @tests << test self end
==(other) 点击切换源代码
能够比较TestSuite
实例是很方便的。
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 97 def ==(other) return false unless(other.kind_of?(self.class)) return false unless(@name == other.name) @tests == other.tests end
delete(test) 点击切换源代码
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 69 def delete(test) @tests.delete(test) end
delete_tests(tests) 点击切换源代码
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 73 def delete_tests(tests) @tests -= tests end
empty?() 点击切换源代码
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 86 def empty? size.zero? end
parallel_safe?() 点击切换源代码
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 43 def parallel_safe? return true if @test_case.nil? @test_case.parallel_safe? end
passed?() 点击切换源代码
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 103 def passed? @tests.all?(&:passed?) end
run(result, runner_class: nil) { |event, *args| ... } 点击切换源代码
运行此TestSuite
中包含的测试和/或套件。
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 50 def run(result, runner_class: nil, &progress_block) runner_class ||= TestSuiteRunner runner_class.new(self).run(result) do |event, *args| case event when STARTED @start_time = Time.now when FINISHED @elapsed_time = Time.now - @start_time end yield(event, *args) end end
size() 点击切换源代码
返回此套件中测试的总数;即,如果套件包含其他套件,则它会计算这些套件内的测试,而不是套件本身。
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 80 def size total_size = 0 @tests.each { |test| total_size += test.size } total_size end
to_s() 点击切换源代码
重写以返回在创建时赋予套件的名称。
# File test-unit-3.6.7/lib/test/unit/testsuite.rb, line 92 def to_s @name end