Module: DTR::TestUnit::TestRunnerMediatorInjection

Defined in:
lib/dtr/test_unit/testrunnermediator_injection.rb

Defined Under Namespace

Classes: SuiteWrapper

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/dtr/test_unit/testrunnermediator_injection.rb', line 36

def self.included(base)
  base.send(:include, Master)
  base.alias_method_chain :create_result, :thread_safe
  base.alias_method_chain :run_suite, :dtr_injection
  #have to use class_eval for adding it back after removed reject_dtr method
  base.class_eval do
    def self.reject_dtr
      remove_method :run_suite
      alias_method :run_suite, :run_suite_without_dtr_injection
      remove_method :run_suite_without_dtr_injection

      remove_method :create_result
      alias_method :create_result, :create_result_without_thread_safe
      remove_method :create_result_without_thread_safe

      (class << self; self; end;).send :remove_method, :reject_dtr
    end
  end
end

Instance Method Details

#create_result_with_thread_safeObject



56
57
58
# File 'lib/dtr/test_unit/testrunnermediator_injection.rb', line 56

def create_result_with_thread_safe
  ThreadSafeTestResult.new(create_result_without_thread_safe)
end

#run_suite_with_dtr_injectionObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/dtr/test_unit/testrunnermediator_injection.rb', line 60

def run_suite_with_dtr_injection
  DTR.logger('dtr_master_process.log')
  # inject testcase&testsuite as late as possible, for it's too easy to be hacked in ruby world
  Test::Unit::TestCase.send(:include, TestUnit::TestCaseInjection)
  Test::Unit::TestSuite.send(:include, TestUnit::TestSuiteInjection)
  @suite = SuiteWrapper.new(@suite.proxy)
  with_dtr_master do
    run_suite_without_dtr_injection
  end
end