Commit 15b5b592 authored by Piotr Stankowski's avatar Piotr Stankowski

Fix junit report attachment in tests with error

Show link to attachment in test report view for tests that are
represented as <error> in junit format report. Before this change only
tests with <failure> had attachment link displayed in test report.

Changelog: fixed
parent 9a2d5688
......@@ -70,6 +70,8 @@ module Gitlab
elsif data.key?('error')
status = ::Gitlab::Ci::Reports::TestCase::STATUS_ERROR
system_output = data['error']
attachment = attachment_path(data['system_out'])
attachment = remove_project_prefix(attachment, job)
elsif data.key?('skipped')
status = ::Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED
system_output = data['skipped']
......
......@@ -444,6 +444,30 @@ RSpec.describe Gitlab::Ci::Parsers::Test::Junit do
end
end
context 'when attachment is specified in test case with error' do
let(:junit) do
<<~EOF
<testsuites>
<testsuite>
<testcase classname='Calculator' name='sumTest1' time='0.01'>
<error>Some error</error>
<system-out>[[ATTACHMENT|some/path.png]]</system-out>
</testcase>
</testsuite>
</testsuites>
EOF
end
it 'assigns correct attributes to the test case' do
expect { subject }.not_to raise_error
expect(test_cases[0].has_attachment?).to be_truthy
expect(test_cases[0].attachment).to eq("some/path.png")
expect(test_cases[0].job).to eq(job)
end
end
private
def flattened_test_cases(test_suite)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment