Class: Gitlab::Ci::Parsers::Test::Junit

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/parsers/test/junit.rb

Constant Summary collapse

JunitParserError =
Class.new(Gitlab::Ci::Parsers::ParserError)
ATTACHMENT_TAG_REGEX =
/\[\[ATTACHMENT\|(?<path>.+?)\]\]/.freeze

Instance Method Summary collapse

Instance Method Details

#parse!(xml_data, test_suite, **args) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/ci/parsers/test/junit.rb', line 11

def parse!(xml_data, test_suite, **args)
  root = Hash.from_xml(xml_data)

  all_cases(root) do |test_case|
    test_case = create_test_case(test_case, args)
    test_suite.add_test_case(test_case)
  end
rescue Nokogiri::XML::SyntaxError => e
  test_suite.set_suite_error("JUnit XML parsing failed: #{e}")
rescue StandardError => e
  test_suite.set_suite_error("JUnit data parsing failed: #{e}")
end