Class: Scan::TestResultParser

Inherits:
Object
  • Object
show all
Defined in:
lib/scan/test_result_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse_result(output) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/scan/test_result_parser.rb', line 3

def parse_result(output)
  # e.g. ...<testsuites tests='2' failures='1'>...
  matched = output.match(/\<testsuites tests='(\d+)' failures='(\d+)'\>/)

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

    return {
      tests: tests,
      failures: failures
    }
  else
    Helper.log.error "Couldn't parse the number of tests from the output".red
    return {}
  end
end