Skip to content

Commit

Permalink
Merge pull request #35 from bugcrowd/timnew-expose-classname-in-junit
Browse files Browse the repository at this point in the history
Expose classname if file attribute does not exist

This is #33 just with some minor tweaks
  • Loading branch information
Tessa Bradbury authored Sep 26, 2018
2 parents 74831d6 + cb1b84b commit 564a26f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ steps:
encoding: UTF-8
strip_colors: true
- label: ":female-technologist: xunit"
artifact_path: spec/sample_artifacts/xunit.xml
artifact_path: spec/sample_artifacts/xunit*.xml
type: junit
- label: ":camel: tap"
artifact_path: spec/sample_artifacts/example.tap
Expand Down Expand Up @@ -87,7 +87,7 @@ steps:
format: '%{location}: %{testcase.name}'
details_regex: '(?<location>\S+:\d+)[^\n]*\z'
- label: ":female-technologist: xunit"
artifact_path: spec/sample_artifacts/xunit.xml
artifact_path: spec/sample_artifacts/xunit*.xml
type: junit
- label: ":camel: tap"
artifact_path: spec/sample_artifacts/example.tap
Expand Down
7 changes: 6 additions & 1 deletion lib/test_summary_buildkite_plugin/input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ def summary(failure)
else
name = data[:'testcase.name']
file = data[:'testcase.file']
location = "#{file}: " unless file.nil? || file.empty?
class_name = data[:'testcase.classname']
location = if !file.nil? && !file.empty?
"#{file}: "
elsif !class_name.nil? && !class_name.empty? && class_name != name
"#{class_name}: "
end
"#{location}#{name}"
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/sample_artifacts/xunit-no-file.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="rspec" tests="1" skipped="0" failures="1" errors="0" time="9.658348" timestamp="2018-04-24T14:55:21+10:00" hostname="foo.local">
<testcase classname="spec.features.test_things_spec" name="test all the things" time="2.068429"><failure message="broken" type="RuntimeError">Failure/Error: fail(&apos;whatever&apos;)

RuntimeError:
whatever
./spec/features/test_things_spec.rb:5:in `block (3 levels) in &lt;top (required)&gt;&apos;</failure></testcase>
</testsuite>
16 changes: 16 additions & 0 deletions spec/test_summary_buildkite_plugin/input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@
end
end

context 'without filename but with classname' do
let(:artifact_path) { 'xunit-no-file.xml' }

it 'includes the classname' do
expect(input.failures.first.summary).to include('spec.features.test_things_spec')
end

context 'that matches name' do
let(:artifact_path) { 'xunit.xml' }

it 'does not repeat the name' do
expect(input.failures.map(&:summary)).to include('Header › matches snapshot')
end
end
end

context 'with summary_format' do
let(:artifact_path) { 'xunit.xml' }
let(:additional_options) do
Expand Down

0 comments on commit 564a26f

Please sign in to comment.