class Scan::TestResultParser

Public Instance Methods

parse_result(output) click to toggle source
# File lib/scan/test_result_parser.rb, line 3
def parse_result(output)
  # e.g. ...<testsuites tests='2' failures='1'>...
  matched = output.scan(/<testsuites\b(?=[^<>]*\s+tests='(\d+)')(?=[^<>]*\s+failures='(\d+)')[^<>]+>/)

  if matched and matched.length == 1 and matched[0].length == 2
    tests = matched[0][0].to_i
    failures = matched[0][1].to_i

    return {
      tests: tests,
      failures: failures
    }
  else
    UI.error("Couldn't parse the number of tests from the output")
    return {}
  end
end