Class: Turn::TestCase
- Inherits:
-
Object
- Object
- Turn::TestCase
- Defined in:
- lib/turn/components/case.rb
Instance Attribute Summary collapse
-
#count_assertions ⇒ Object
This can;t be calculated, so it must be assigned by the runner.
-
#files ⇒ Object
Some runners marshal tests per file.
-
#message ⇒ Object
Holds dump of test output (optional depending on runner).
-
#name ⇒ Object
Name of test case.
-
#tests ⇒ Object
Test methods.
Instance Method Summary collapse
- #count_errors ⇒ Object
- #count_failures ⇒ Object
- #count_passes ⇒ Object
- #count_tests ⇒ Object
- #counts ⇒ Object
-
#error? ⇒ Boolean
Were there any errors?.
-
#fail? ⇒ Boolean
Were there any failures?.
-
#initialize(name, *files) ⇒ TestCase
constructor
A new instance of TestCase.
- #new_test(name) ⇒ Object
-
#pass? ⇒ Boolean
Did all tests/assertion pass?.
Constructor Details
#initialize(name, *files) ⇒ TestCase
Returns a new instance of TestCase.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/turn/components/case.rb', line 31 def initialize(name, *files) @name = name @files = (files.empty? ? [name] : files) @tests = [] @message = nil @count_assertions = 0 #@count_tests = 0 #@count_failures = 0 #@count_errors = 0 #@command = command end |
Instance Attribute Details
#count_assertions ⇒ Object
This can;t be calculated, so it must be assigned by the runner.
22 23 24 |
# File 'lib/turn/components/case.rb', line 22 def count_assertions @count_assertions end |
#files ⇒ Object
Some runners marshal tests per file.
13 14 15 |
# File 'lib/turn/components/case.rb', line 13 def files @files end |
#message ⇒ Object
Holds dump of test output (optional depending on runner).
25 26 27 |
# File 'lib/turn/components/case.rb', line 25 def @message end |
#name ⇒ Object
Name of test case.
7 8 9 |
# File 'lib/turn/components/case.rb', line 7 def name @name end |
#tests ⇒ Object
Test methods.
10 11 12 |
# File 'lib/turn/components/case.rb', line 10 def tests @tests end |
Instance Method Details
#count_errors ⇒ Object
78 79 80 |
# File 'lib/turn/components/case.rb', line 78 def count_errors sum = 0; tests.each{ |t| sum += 1 if t.error? }; sum end |
#count_failures ⇒ Object
74 75 76 |
# File 'lib/turn/components/case.rb', line 74 def count_failures sum = 0; tests.each{ |t| sum += 1 if t.fail? }; sum end |
#count_passes ⇒ Object
82 83 84 |
# File 'lib/turn/components/case.rb', line 82 def count_passes sum = 0; tests.each{ |t| sum += 1 if t.pass? }; sum end |
#count_tests ⇒ Object
70 71 72 |
# File 'lib/turn/components/case.rb', line 70 def count_tests tests.size end |
#counts ⇒ Object
87 88 89 |
# File 'lib/turn/components/case.rb', line 87 def counts return count_tests, count_assertions, count_failures, count_errors end |
#error? ⇒ Boolean
Were there any errors?
56 57 58 |
# File 'lib/turn/components/case.rb', line 56 def error? count_errors != 0 end |
#fail? ⇒ Boolean
Were there any failures?
61 62 63 |
# File 'lib/turn/components/case.rb', line 61 def fail? count_failures != 0 end |
#new_test(name) ⇒ Object
46 47 48 49 50 |
# File 'lib/turn/components/case.rb', line 46 def new_test(name) c = TestMethod.new(name) @tests << c c end |
#pass? ⇒ Boolean
Did all tests/assertion pass?
66 67 68 |
# File 'lib/turn/components/case.rb', line 66 def pass? not(fail? or error?) end |