Class: Test::Unit::TestSuite

Inherits:
Object
  • Object
show all
Defined in:
lib/test/unit/testsuite_xml.rb

Instance Method Summary collapse

Instance Method Details

#run_with_timing(result, &block) ⇒ Object Also known as: run



8
9
10
11
12
13
14
# File 'lib/test/unit/testsuite_xml.rb', line 8

def run_with_timing(result, &block)
  @before_time = Time.now
  run_without_timing(result, &block)
ensure
  after_time = Time.now.to_f
  @elapsed_time = after_time - @before_time.to_f
end

#xml_elementObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/test/unit/testsuite_xml.rb', line 18

def xml_element
  node = if @tests.first.is_a?(TestSuite)
    REXML::Element.new("testsuites")
  else
    testsuite = REXML::Element.new("testsuite")
    testsuite.add_attributes(
      'name' => @name,
      'tests' => test_count.to_s,
      'failures' => failure_count.to_s,
      'errors' => error_count.to_s,
      'time' => @elapsed_time.to_s,
      'timestamp' => @before_time.xmlschema
    )
    testsuite
  end
  
  @tests.each do |test|
    xml_element = test.xml_element
    node.elements << xml_element if xml_element
  end
  return nil if node.elements.empty?
  node
end