Class: Rproof::TestSuite

Inherits:
Test
  • Object
show all
Defined in:
lib/rproof/test_suite.rb

Instance Method Summary collapse

Methods inherited from Test

#clean_up, #setup

Constructor Details

#initialize(reporter, name, description = nil) ⇒ TestSuite

Returns a new instance of TestSuite.



9
10
11
12
13
# File 'lib/rproof/test_suite.rb', line 9

def initialize(reporter, name, description = nil)
  super(reporter, name, description)
  @tests = []
  @test_results = []
end

Instance Method Details

#executeObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rproof/test_suite.rb', line 30

def execute
  @reporter.report_suite_begin(@id, @name, @description)
  begin
    setup
    run
    clean_up
  rescue Exception => e
    @censor.log_exception e
    @test_results << @censor.test_result
  end
  @reporter.report_suite_end(@id, @test_results)
  @test_results
end

#get_tests(filename_pattern) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rproof/test_suite.rb', line 44

def get_tests(filename_pattern)
  tests = []
  if nil != self.class.name.downcase.match(filename_pattern.downcase)
    tests << self
  else
    @tests.each do |test|
      if test.is_a? Test_Suite
        tests << test.get_tests(filename_pattern)
      else
        tests << test if nil != test.class.name.downcase.match(filename_pattern.downcase)
      end
    end
  end
  tests
end

#register(test) ⇒ Object

Register a Test to be run



16
17
18
# File 'lib/rproof/test_suite.rb', line 16

def register(test)
  @tests << test
end

#runObject



24
25
26
27
28
# File 'lib/rproof/test_suite.rb', line 24

def run
  @tests.shuffle.each do |test|
    @test_results << test.execute
  end
end

#unregister_allObject



20
21
22
# File 'lib/rproof/test_suite.rb', line 20

def unregister_all
  @tests = []
end