sj26 / rspec_junit_formatter

RSpec results that your CI can read

Home Page:http://rubygems.org/gems/rspec_junit_formatter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

does not support testsuites

KlotzAndrew opened this issue · comments

all tests look like they in a single testsuite, where I would expect describe blocks to group multiple testsuite blocks under a testsuites block

example with 2 describe blocks:

require "spec_helper"

describe "testsuite_1" do
  it "test_1" do
    expect(true).to be(true)
  end
end

describe "testsuite_2" do
  it "test_1" do
    expect(true).to be(true)
  end
end

console output is grouped by describe block:

rspec --format documentation --format RspecJunitFormatter --out rspec.xml
testsuite_1
  test_1

testsuite_2
  test_1

Finished in 0.00064 seconds (files took 0.04847 seconds to load)
2 examples, 0 failures

but the xml groups all tests in a single testsuite block:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="rspec" tests="2" skipped="0" failures="0" errors="0" time="0.000643" timestamp="2019-12-21T14:25:25-05:00" hostname="ubuntu">
   <properties>
      <property name="seed" value="33194" />
   </properties>
   <testcase classname="spec.example_spec" name="testsuite_1 test_1" file="./spec/example_spec.rb" time="0.000235" />
   <testcase classname="spec.example_spec" name="testsuite_2 test_1" file="./spec/example_spec.rb" time="0.000040" />
</testsuite>

In junit, test suites are java namespaces, and will be combined with dots when presented. This is directly at odds with rspec example group and example naming, which encourages natural language syntax, joined with spaces and forming simple sentences or statements. The compromise was to output a single test suite, with test cases descriptions based on the rspec example group and example descriptions, but with namespaced class names based on the path to the containing example file. Most tools will fold the class names into a navigable tree structure, and I'd encourage you to do so if that's what you're after. 🙏