diff options
author | Fabio Pitino <fpitino@gitlab.com> | 2019-05-17 08:31:39 +0100 |
---|---|---|
committer | Fabio Pitino <fpitino@gitlab.com> | 2019-05-17 08:31:39 +0100 |
commit | 82778a879665000fad1d2b2637bfbe8efd72d97a (patch) | |
tree | 2f64d59ae3c75c57f349d6b00acf923406d10fec | |
parent | 8dd40cfdca449b1921a07924737dda22ed51c905 (diff) | |
parent | 93303c78cf99734b6f1c7e8fd899ff4b1f246a83 (diff) | |
download | gitlab-ce-82778a879665000fad1d2b2637bfbe8efd72d97a.tar.gz |
Rebase on master
-rw-r--r-- | lib/gitlab/ci/reports/test_case.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/parsers/test/junit_spec.rb | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/gitlab/ci/reports/test_case.rb b/lib/gitlab/ci/reports/test_case.rb index 292e273a03a..3e061a9b672 100644 --- a/lib/gitlab/ci/reports/test_case.rb +++ b/lib/gitlab/ci/reports/test_case.rb @@ -14,7 +14,7 @@ module Gitlab def initialize(name:, classname:, execution_time:, status:, file: nil, system_output: nil, stack_trace: nil) @name = name - @classname = classname + @classname = classname.present? ? classname : file @file = file @execution_time = execution_time.to_f @status = status diff --git a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb index a49402c7398..e1ab3b2e367 100644 --- a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb +++ b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb @@ -116,6 +116,30 @@ describe Gitlab::Ci::Parsers::Test::Junit do end end + context 'when there are two test cases without classname' do + let(:junit) do + <<-EOF.strip_heredoc + <testsuite> + <testcase name='sumTest1' time='0.01' file='./path/to/file1'></testcase> + <testcase name='sumTest2' time='0.02' file='./path/to/file2'></testcase> + </testsuite> + EOF + end + + it 'parses XML and adds test cases to a suite defaulting classname to file attribute' do + expect { subject }.not_to raise_error + + expect(test_cases[0].classname).to eq('./path/to/file1') + expect(test_cases[0].file).to eq('./path/to/file1') + expect(test_cases[0].name).to eq('sumTest1') + expect(test_cases[0].execution_time).to eq(0.01) + expect(test_cases[1].classname).to eq('./path/to/file2') + expect(test_cases[1].file).to eq('./path/to/file2') + expect(test_cases[1].name).to eq('sumTest2') + expect(test_cases[1].execution_time).to eq(0.02) + end + end + context 'when there are two test suites' do let(:junit) do <<-EOF.strip_heredoc |