Class: GUnit::TestRunner
- Inherits:
-
Object
- Object
- GUnit::TestRunner
- Defined in:
- lib/gunit/test_runner.rb
Overview
A TestRunner object discovers TestCase classes The TestRunner object calls suite() on all TestCase classes Each TestCase class returns a TestSuite object with instances of itself (TestCases) each with a method to be executed The TestRunner object calls run() on all TestSuite objects, collecting TestResponses Each TestSuite object calls run() on all of its TestCase objects, yielding TestResponses Each TestCase object executes its method, returning a TestResponse The TestRunner displays the TestResponses as they are yielded After all tests have run, the TestRunner displays a summery of results
Constant Summary collapse
- PASS_CHAR =
'.'
- FAIL_CHAR =
'F'
- TODO_CHAR =
'*'
- EXCEPTION_CHAR =
'E'
Instance Attribute Summary collapse
-
#io ⇒ Object
TestSuites and/or TestCases.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
-
#silent ⇒ Object
TestSuites and/or TestCases.
- #tests ⇒ Object
Instance Method Summary collapse
- #exceptions ⇒ Object
- #fails ⇒ Object
-
#initialize(*args) ⇒ TestRunner
constructor
A new instance of TestRunner.
- #passes ⇒ Object
- #run ⇒ Object
- #to_dos ⇒ Object
Constructor Details
#initialize(*args) ⇒ TestRunner
Returns a new instance of TestRunner.
29 30 31 32 33 34 |
# File 'lib/gunit/test_runner.rb', line 29 def initialize(*args) @responses = [] @io = STDOUT STDOUT.sync = true @silent = false end |
Instance Attribute Details
#io ⇒ Object
TestSuites and/or TestCases
25 26 27 |
# File 'lib/gunit/test_runner.rb', line 25 def io @io end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
27 28 29 |
# File 'lib/gunit/test_runner.rb', line 27 def responses @responses end |
#silent ⇒ Object
TestSuites and/or TestCases
25 26 27 |
# File 'lib/gunit/test_runner.rb', line 25 def silent @silent end |
#tests ⇒ Object
36 37 38 |
# File 'lib/gunit/test_runner.rb', line 36 def tests @tests ||= [] end |
Instance Method Details
#exceptions ⇒ Object
72 73 74 |
# File 'lib/gunit/test_runner.rb', line 72 def exceptions @responses.find_all{|r| r.is_a? ExceptionResponse } end |
#fails ⇒ Object
68 69 70 |
# File 'lib/gunit/test_runner.rb', line 68 def fails @responses.find_all{|r| r.is_a? FailResponse } end |
#passes ⇒ Object
64 65 66 |
# File 'lib/gunit/test_runner.rb', line 64 def passes @responses.find_all{|r| r.is_a? PassResponse } end |
#run ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gunit/test_runner.rb', line 40 def run self.tests.each do |test| case when test.is_a?(TestSuite) test.run do |response| @responses << response @io.print self.class.response_character(response) unless self.silent end when test.is_a?(TestCase) response = test.run @responses << response @io.print self.class.response_character(response) unless self.silent end end unless self.silent @io.puts "" fails.each do |fail| @io.puts "#{fail.} (#{fail.file_name}:#{fail.line_number})" end @io.puts "#{@responses.length} verifications: #{passes.length} passed, #{fails.length} failed, #{exceptions.length} exceptions, #{to_dos.length} to-dos" end end |
#to_dos ⇒ Object
76 77 78 |
# File 'lib/gunit/test_runner.rb', line 76 def to_dos @responses.find_all{|r| r.is_a? ToDoResponse } end |