diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-04 00:07:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-04 00:07:29 +0300 |
commit | 1da3754b25657f49afdcb0b942506d365b1ee89d (patch) | |
tree | 9f4bfa94fdd1762ef99e6a61bf180ac8cd7b5616 /spec/lib/gitlab/ci | |
parent | 25521def84a6987fe9d4265b560e930bfb32c195 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/parsers/test/junit_spec.rb | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb index 8ff60710f67..6a7fe7a5927 100644 --- a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb +++ b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb @@ -38,12 +38,14 @@ describe Gitlab::Ci::Parsers::Test::Junit do end end - context 'when there is only one <testcase> in <testsuite>' do + context 'when there is only one <testsuite> in <testsuites>' do let(:junit) do <<-EOF.strip_heredoc - <testsuite> - <testcase classname='Calculator' name='sumTest1' time='0.01'></testcase> - </testsuite> + <testsuites> + <testsuite> + <testcase classname='Calculator' name='sumTest1' time='0.01'></testcase> + </testsuite> + </testsuites> EOF end @@ -56,23 +58,65 @@ describe Gitlab::Ci::Parsers::Test::Junit do end end - context 'when there is only one <testsuite> in <testsuites>' do + context 'when there is <testcase>' do let(:junit) do <<-EOF.strip_heredoc - <testsuites> <testsuite> - <testcase classname='Calculator' name='sumTest1' time='0.01'></testcase> + <testcase classname='Calculator' name='sumTest1' time='0.01'> + #{testcase_content} + </testcase> </testsuite> - </testsuites> EOF end - it 'parses XML and adds a test case to a suite' do + let(:test_case) { test_cases[0] } + + before do expect { subject }.not_to raise_error + end - expect(test_cases[0].classname).to eq('Calculator') - expect(test_cases[0].name).to eq('sumTest1') - expect(test_cases[0].execution_time).to eq(0.01) + shared_examples_for '<testcase> XML parser' do |status, output| + it 'parses XML and adds a test case to the suite' do + aggregate_failures do + expect(test_case.classname).to eq('Calculator') + expect(test_case.name).to eq('sumTest1') + expect(test_case.execution_time).to eq(0.01) + expect(test_case.status).to eq(status) + expect(test_case.system_output).to eq(output) + end + end + end + + context 'and has failure' do + let(:testcase_content) { '<failure>Some failure</failure>' } + + it_behaves_like '<testcase> XML parser', + ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED, + 'Some failure' + end + + context 'and has error' do + let(:testcase_content) { '<error>Some error</error>' } + + it_behaves_like '<testcase> XML parser', + ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED, + 'Some error' + end + + context 'and has an unknown type' do + let(:testcase_content) { '<foo>Some foo</foo>' } + + it_behaves_like '<testcase> XML parser', + ::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS, + nil + end + + context 'and has no content' do + let(:testcase_content) { '' } + + it_behaves_like '<testcase> XML parser', + ::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS, + nil end end |