Class: Mxrb::Functional::Reporter
- Inherits:
-
Object
- Object
- Mxrb::Functional::Reporter
- Defined in:
- lib/mxrb/functional.rb
Instance Method Summary collapse
Instance Method Details
#write_json(execution, path) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/mxrb/functional.rb', line 271 def write_json(execution, path) payload = { passed: execution.passed?, finished: execution.result.finished?, elapsed: execution.elapsed, tests: execution.result.tests.map do |test| { name: test.name, passed: test.passed?, message: test. } end } File.write(path, JSON.pretty_generate(payload) << "\n") path end |
#write_junit(execution, path) ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/mxrb/functional.rb', line 284 def write_junit(execution, path) tests = execution.result.tests failures = tests.count(&:failed?) cases = tests.map do |test| name = CGI.escapeHTML(test.name) if test.passed? %( <testcase name="#{name}"/>) else = CGI.escapeHTML(test.) %( <testcase name="#{name}"><failure message="#{}"/></testcase>) end end.join("\n") xml = <<~XML <?xml version="1.0" encoding="UTF-8"?> <testsuite name="mxrb" tests="#{tests.size}" failures="#{failures}" time="#{execution.elapsed}"> #{cases} </testsuite> XML File.write(path, xml) path end |