Module: CircleCI::TestReport
- Defined in:
- lib/circleci/test_report.rb,
lib/circleci/test_report/cli.rb,
lib/circleci/test_report/version.rb,
lib/circleci/test_report/test_case.rb,
lib/circleci/test_report/test_suite.rb
Defined Under Namespace
Classes: Cli, TestCase, TestSuite
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
Class Method Details
.create_xml(rspec_json:, timestamp: Time.now.iso8601, hostname: "unknown") ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/circleci/test_report.rb', line 10 def create_xml(rspec_json:, timestamp: Time.now.iso8601, hostname: "unknown") rspec_hash = JSON.parse(rspec_json) summary = rspec_hash["summary"] suite = TestSuite.new suite.name = "rspec" suite.tests = summary["example_count"] suite.skipped = summary["pending_count"] suite.failures = summary["failure_count"] suite.errors = summary["errors_outside_of_examples_count"] suite.time = summary["duration"] suite. = suite.hostname = hostname suite.seed = 0 rspec_hash["examples"].each do |example| testcase = TestCase.new testcase.classname = example["file_path"].split(".")[1].split("/")[1..-1].join(".") testcase.name = example["full_description"] testcase.file = example["file_path"] testcase.time = example["run_time"] case example["status"] when "failed" exception = example["exception"] testcase.failure = { message: exception["message"], type: exception["class"], text: exception["backtrace"] ? exception["backtrace"].join("\n") : '' } when "pending" testcase.skipped = true end suite.add_test_case(testcase) end suite.to_xml end |