Class: CircleCI::TestReport::TestSuite

Inherits:
Object
  • Object
show all
Defined in:
lib/circleci/test_report/test_suite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestSuite

Returns a new instance of TestSuite.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/circleci/test_report/test_suite.rb', line 8

def initialize
  @test_cases = []
  @name       = ""
  @tests      = 0
  @skipped    = 0
  @failures   = 0
  @errors     = 0
  @time       = 0
  @timestamp  = nil
  @seed       = 0
  @hostname   = ""
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def errors
  @errors
end

#failuresObject

Returns the value of attribute failures.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def failures
  @failures
end

#hostnameObject

Returns the value of attribute hostname.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def hostname
  @hostname
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def name
  @name
end

#seedObject

Returns the value of attribute seed.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def seed
  @seed
end

#skippedObject

Returns the value of attribute skipped.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def skipped
  @skipped
end

#test_casesObject

Returns the value of attribute test_cases.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def test_cases
  @test_cases
end

#testsObject

Returns the value of attribute tests.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def tests
  @tests
end

#timeObject

Returns the value of attribute time.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def time
  @time
end

#timestampObject

Returns the value of attribute timestamp.



6
7
8
# File 'lib/circleci/test_report/test_suite.rb', line 6

def timestamp
  @timestamp
end

Instance Method Details

#add_test_case(testcase) ⇒ Object



21
22
23
# File 'lib/circleci/test_report/test_suite.rb', line 21

def add_test_case(testcase)
  @test_cases << testcase
end

#to_xmlObject



25
26
27
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
# File 'lib/circleci/test_report/test_suite.rb', line 25

def to_xml
  xml_markup = Builder::XmlMarkup.new
  xml_markup.instruct!
  xml_markup.testsuite(name:      name,
                       tests:     tests,
                       skipped:   skipped,
                       failures:  failures,
                       errors:    errors,
                       time:      time,
                       timestamp: timestamp,
                       hostname:  hostname) do |testsuite|

    testsuite.properties { |p| p.property(name: "seed", value: seed) }

    test_cases.each do |test_case|
      testsuite.testcase(classname: test_case.classname,
                         name:      test_case.name,
                         file:      test_case.file,
                         time:      test_case.time) do |t|
        if test_case.failure
          t.failure(message: test_case.failure[:message], type: test_case.failure[:type]) do |f|
            f.text! test_case.failure[:text]
          end
        elsif test_case.skipped
          t.skipped
        end
      end
    end
  end
end