Class: DTR::Agent::TestCase

Inherits:
Object show all
Defined in:
lib/dtr/agent/test_case.rb

Instance Method Summary collapse

Constructor Details

#initialize(test, result, &progress_block) ⇒ TestCase

Returns a new instance of TestCase.



20
21
22
23
24
# File 'lib/dtr/agent/test_case.rb', line 20

def initialize(test, result, &progress_block)
  @test = test
  @result = result
  @progress_block = progress_block
end

Instance Method Details

#add_error(e) ⇒ Object



46
47
48
49
50
# File 'lib/dtr/agent/test_case.rb', line 46

def add_error(e)
  @result.add_error(Test::Unit::Error.new(@test.name, RemoteError.new(e)))
  @result.add_run
  @progress_block.call(Test::Unit::TestCase::FINISHED, @test.name)
end

#runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dtr/agent/test_case.rb', line 26

def run
  if @test.is_a?(DRb::DRbUnknown)
    add_error(UnknownTestError.new("No such test loaded: #{@test.name}"))
  else
    @test.run(@result, &@progress_block)
  end
rescue DRb::DRbConnError => e
  msg = "Rescued DRb::DRbConnError(#{e.message}), while running test: #{test}. The master process may be stopped."
  DTR.do_println(msg)
  DTR.info {msg}
rescue Exception => e
  unexpected_error(e)
end

#unexpected_error(e) ⇒ Object



40
41
42
43
44
# File 'lib/dtr/agent/test_case.rb', line 40

def unexpected_error(e)
  DTR.error "Unexpected exception: #{e.message}"
  DTR.error e.backtrace.join("\n")
  add_error(e)
end