Class: JunitReportGenerator::TestSuite

Inherits:
Element
  • Object
show all
Defined in:
lib/junit_report_generator/elements/test_suite.rb

Instance Attribute Summary

Attributes included from Elementary

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

create

Methods included from Elementary

#assemble_attributes, #method_missing, #update_attributes

Constructor Details

#initialize(name) ⇒ TestSuite

Returns a new instance of TestSuite.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/junit_report_generator/elements/test_suite.rb', line 11

def initialize(name)
  @name = name
  @tests = 0
  @errors = 0
  @failures = 0
  @skipped = 0
  @time = 0
  assemble_attributes(:name, :tests, :errors, :failures, :skipped, :time)
  register do |sub_elements|
    sub_elements.each do |sub_element|
      if sub_element.is_a?(TestCase)
        @tests += 1
        @time += sub_element.attributes.fetch(:time, 0).to_f
        class_types = sub_element.sub_elements.map(&:class)
        @errors += 1 if class_types.include?(Error)
        @failures += 1 if class_types.include?(Failure)
        @skipped += 1 if class_types.include?(Skipped)
      end
    end
    update_attributes(:tests, :errors, :failures, :skipped, :time)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JunitReportGenerator::Elementary

Class Method Details

.xml_tag_nameObject



35
36
37
# File 'lib/junit_report_generator/elements/test_suite.rb', line 35

def xml_tag_name
  'testsuite'
end