Class: Turn::TestCase
- Inherits:
-
Object
- Object
- Turn::TestCase
- Includes:
- Enumerable
- 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
-
#name ⇒ Object
Name of test case.
-
#tests ⇒ Object
Test methods.
Instance Method Summary collapse
- #count_errors ⇒ Object
- #count_failures ⇒ Object
- #count_passes ⇒ Object
- #count_skips ⇒ Object
- #count_tests ⇒ Object (also: #size)
- #counts ⇒ Object
- #each(&block) ⇒ 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/turn/components/case.rb', line 32 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.
23 24 25 |
# File 'lib/turn/components/case.rb', line 23 def count_assertions @count_assertions end |
#files ⇒ Object
Some runners marshal tests per file.
14 15 16 |
# File 'lib/turn/components/case.rb', line 14 def files @files end |
#message ⇒ Object
99 100 101 |
# File 'lib/turn/components/case.rb', line 99 def tests.collect{ |t| t. }.join("\n") end |
#name ⇒ Object
Name of test case.
8 9 10 |
# File 'lib/turn/components/case.rb', line 8 def name @name end |
#tests ⇒ Object
Test methods.
11 12 13 |
# File 'lib/turn/components/case.rb', line 11 def tests @tests end |
Instance Method Details
#count_errors ⇒ Object
81 82 83 |
# File 'lib/turn/components/case.rb', line 81 def count_errors sum = 0; tests.each{ |t| sum += 1 if t.error? }; sum end |
#count_failures ⇒ Object
77 78 79 |
# File 'lib/turn/components/case.rb', line 77 def count_failures sum = 0; tests.each{ |t| sum += 1 if t.fail? }; sum end |
#count_passes ⇒ Object
85 86 87 |
# File 'lib/turn/components/case.rb', line 85 def count_passes sum = 0; tests.each{ |t| sum += 1 if t.pass? }; sum end |
#count_skips ⇒ Object
89 90 91 92 |
# File 'lib/turn/components/case.rb', line 89 def count_skips # Why not use tests.select(&:skip?).size ? sum = 0; tests.each{ |t| sum += 1 if t.skip? }; sum end |
#count_tests ⇒ Object Also known as: size
71 72 73 |
# File 'lib/turn/components/case.rb', line 71 def count_tests tests.size end |
#counts ⇒ Object
95 96 97 |
# File 'lib/turn/components/case.rb', line 95 def counts return count_tests, count_assertions, count_failures, count_errors, count_skips end |
#each(&block) ⇒ Object
103 104 105 |
# File 'lib/turn/components/case.rb', line 103 def each(&block) tests.each(&block) end |
#error? ⇒ Boolean
Were there any errors?
57 58 59 |
# File 'lib/turn/components/case.rb', line 57 def error? count_errors != 0 end |
#fail? ⇒ Boolean
Were there any failures?
62 63 64 |
# File 'lib/turn/components/case.rb', line 62 def fail? count_failures != 0 end |
#new_test(name) ⇒ Object
47 48 49 50 51 |
# File 'lib/turn/components/case.rb', line 47 def new_test(name) c = TestMethod.new(name) @tests << c c end |
#pass? ⇒ Boolean
Did all tests/assertion pass?
67 68 69 |
# File 'lib/turn/components/case.rb', line 67 def pass? not(fail? or error?) end |