Class: DTest::Global::Harness
- Inherits:
-
Object
- Object
- DTest::Global::Harness
- Includes:
- Hook
- Defined in:
- lib/dtest/global.rb
Instance Attribute Summary collapse
-
#after ⇒ Object
Returns the value of attribute after.
-
#before ⇒ Object
Returns the value of attribute before.
-
#global ⇒ Object
Returns the value of attribute global.
-
#shared_contexts ⇒ Object
Returns the value of attribute shared_contexts.
Instance Method Summary collapse
- #execute_after(list, context) ⇒ Object
- #execute_testcase(global_result, testcase) ⇒ Object
-
#initialize ⇒ Harness
constructor
A new instance of Harness.
- #start(testcases) ⇒ Object
Methods included from Hook
Constructor Details
#initialize ⇒ Harness
Returns a new instance of Harness.
14 15 16 17 18 |
# File 'lib/dtest/global.rb', line 14 def initialize @before = [] @after = [] @shared_contexts = [] end |
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after.
11 12 13 |
# File 'lib/dtest/global.rb', line 11 def after @after end |
#before ⇒ Object
Returns the value of attribute before.
11 12 13 |
# File 'lib/dtest/global.rb', line 11 def before @before end |
#global ⇒ Object
Returns the value of attribute global.
10 11 12 |
# File 'lib/dtest/global.rb', line 10 def global @global end |
#shared_contexts ⇒ Object
Returns the value of attribute shared_contexts.
12 13 14 |
# File 'lib/dtest/global.rb', line 12 def shared_contexts @shared_contexts end |
Instance Method Details
#execute_after(list, context) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/dtest/global.rb', line 20 def execute_after(list, context) begin exec(list, context) rescue StandardError, Exception => e # にぎりつぶす end end |
#execute_testcase(global_result, testcase) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/dtest/global.rb', line 72 def execute_testcase(global_result, testcase) begin # execute TestCases testcase.execute(global_result) rescue AbortTest, AbortTestCase => e # にぎりつぶす end end |
#start(testcases) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/dtest/global.rb', line 28 def start(testcases) # Progress global_values = Object.new context = Context.new(global_values) unless @shared_contexts.empty? i = DTest::SharedContext::Manager::instance @shared_contexts.each { |name| context.instance_eval(&i.contexts[name]) } context end Progress.setUpGlobal(testcases) global_result = Test::GlobalResult.new(testcases) @before.each {|b| b.result = global_result.before_failure } @after.each {|b| b.result = global_result.after_failure } global_result.timer { begin # execute before exec(@before, context) # execute cases testcases.each do |testcase| testcase.shared_contexts = shared_contexts testcase.defined_values = global_values.clone execute_testcase(global_result, testcase) end rescue AbortGlobal => e # finish rescue StandardError, Exception => e # Blockでエラー処理しているので、にぎりつぶす ensure execute_after(@after, context) Progress.tearDownGlobal end } global_result end |