Class: DTest::Test::Case
Instance Attribute Summary collapse
-
#after ⇒ Object
Returns the value of attribute after.
-
#afterCase ⇒ Object
Returns the value of attribute afterCase.
-
#before ⇒ Object
Returns the value of attribute before.
-
#beforeCase ⇒ Object
Returns the value of attribute beforeCase.
-
#defined_values ⇒ Object
Returns the value of attribute defined_values.
-
#name ⇒ Object
Returns the value of attribute name.
-
#shared_contexts ⇒ Object
Returns the value of attribute shared_contexts.
-
#test ⇒ Object
Returns the value of attribute test.
Instance Method Summary collapse
- #execute(global_result) ⇒ Object
-
#initialize(name, beforeCase, afterCase, before, after, test, local_contexts) ⇒ Case
constructor
A new instance of Case.
Methods included from Hook
Constructor Details
#initialize(name, beforeCase, afterCase, before, after, test, local_contexts) ⇒ Case
Returns a new instance of Case.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dtest/test.rb', line 17 def initialize(name, beforeCase, afterCase, before, after, test, local_contexts) @name = name @beforeCase = beforeCase @afterCase = afterCase @before = before @after = after @test = test @defined_values = Object.new @shared_contexts = [] @local_contexts = local_contexts end |
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after.
12 13 14 |
# File 'lib/dtest/test.rb', line 12 def after @after end |
#afterCase ⇒ Object
Returns the value of attribute afterCase.
11 12 13 |
# File 'lib/dtest/test.rb', line 11 def afterCase @afterCase end |
#before ⇒ Object
Returns the value of attribute before.
12 13 14 |
# File 'lib/dtest/test.rb', line 12 def before @before end |
#beforeCase ⇒ Object
Returns the value of attribute beforeCase.
11 12 13 |
# File 'lib/dtest/test.rb', line 11 def beforeCase @beforeCase end |
#defined_values ⇒ Object
Returns the value of attribute defined_values.
14 15 16 |
# File 'lib/dtest/test.rb', line 14 def defined_values @defined_values end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/dtest/test.rb', line 10 def name @name end |
#shared_contexts ⇒ Object
Returns the value of attribute shared_contexts.
15 16 17 |
# File 'lib/dtest/test.rb', line 15 def shared_contexts @shared_contexts end |
#test ⇒ Object
Returns the value of attribute test.
13 14 15 |
# File 'lib/dtest/test.rb', line 13 def test @test end |
Instance Method Details
#execute(global_result) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/dtest/test.rb', line 102 def execute(global_result) # TestCase result caseresult = CaseResult.new(@name) global_result.add(caseresult) # set result @beforeCase.each {|b| b.result = caseresult.before_failure } @afterCase.each {|b| b.result = caseresult.after_failure } Progress.setUpTestCase(name, @test.size) executed = 0 passed = 0 context = create_context begin caseresult.timer { # execute beforeCase exec(@beforeCase, context) # execute each test @test.each do |test| executed += 1 result = Result.new(test.name) caseresult.add(result) execute_test(result, test) passed += 1 if result.result == Result::PASS end } # Stopwatch::timer rescue AbortTestCase # にぎりつぶす ensure # report caseresult.passed = passed caseresult.failed = executed - passed caseresult.executed = executed caseresult.untested = @test.size - executed # execute afterCase begin execute_after_case(@afterCase, context) ensure # report testcase finished Progress.tearDownTestCase(name, executed, caseresult.elapsed) end end end |