Commit 909dee38 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix/attachment-in-test-report-with-error' into 'master'

Fix junit report attachment in tests with "error" result

See merge request gitlab-org/gitlab!62874
parents a2195208 15b5b592
......@@ -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