diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-08-03 21:39:48 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-08-03 21:39:48 +0300 |
commit | 99c033f2888a96267aa0443ad7a07f1f0e861992 (patch) | |
tree | a1d7bb68dfaba668987705538bfa4526c473010d /spec/support | |
parent | 53ecd2e147eb24f7e53385cb21f0c9759a482d6c (diff) | |
parent | fafd1764ca71156d261a604d64b43d531667cb17 (diff) |
Merge branch 'artifact-format-v2-with-parser' into 'master'
Parse junit.xml.gz and calculate the difference between head and base
See merge request gitlab-org/gitlab-ce!20576
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/helpers/reactive_caching_helpers.rb | 4 | ||||
-rw-r--r-- | spec/support/test_reports/test_reports_helper.rb | 93 |
2 files changed, 95 insertions, 2 deletions
diff --git a/spec/support/helpers/reactive_caching_helpers.rb b/spec/support/helpers/reactive_caching_helpers.rb index e22dd974c6a..a575aa99b79 100644 --- a/spec/support/helpers/reactive_caching_helpers.rb +++ b/spec/support/helpers/reactive_caching_helpers.rb @@ -14,8 +14,8 @@ module ReactiveCachingHelpers end def synchronous_reactive_cache(subject) - allow(service).to receive(:with_reactive_cache) do |*args, &block| - block.call(service.calculate_reactive_cache(*args)) + allow(subject).to receive(:with_reactive_cache) do |*args, &block| + block.call(subject.calculate_reactive_cache(*args)) end end diff --git a/spec/support/test_reports/test_reports_helper.rb b/spec/support/test_reports/test_reports_helper.rb new file mode 100644 index 00000000000..45c6e04dbf3 --- /dev/null +++ b/spec/support/test_reports/test_reports_helper.rb @@ -0,0 +1,93 @@ +module TestReportsHelper + def create_test_case_rspec_success + Gitlab::Ci::Reports::TestCase.new( + name: 'Test#sum when a is 1 and b is 3 returns summary', + classname: 'spec.test_spec', + file: './spec/test_spec.rb', + execution_time: 1.11, + status: Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS) + end + + def create_test_case_rspec_failed + Gitlab::Ci::Reports::TestCase.new( + name: 'Test#sum when a is 2 and b is 2 returns summary', + classname: 'spec.test_spec', + file: './spec/test_spec.rb', + execution_time: 2.22, + system_output: sample_rspec_failed_message, + status: Gitlab::Ci::Reports::TestCase::STATUS_FAILED) + end + + def create_test_case_rspec_skipped + Gitlab::Ci::Reports::TestCase.new( + name: 'Test#sum when a is 3 and b is 3 returns summary', + classname: 'spec.test_spec', + file: './spec/test_spec.rb', + execution_time: 3.33, + status: Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED) + end + + def create_test_case_rspec_error + Gitlab::Ci::Reports::TestCase.new( + name: 'Test#sum when a is 4 and b is 4 returns summary', + classname: 'spec.test_spec', + file: './spec/test_spec.rb', + execution_time: 4.44, + status: Gitlab::Ci::Reports::TestCase::STATUS_ERROR) + end + + def sample_rspec_failed_message + <<-EOF.strip_heredoc + Failure/Error: is_expected.to eq(3) + + expected: 3 + got: -1 + + (compared using ==) + ./spec/test_spec.rb:12:in `block (4 levels) in <top (required)>' + EOF + end + + def create_test_case_java_success + Gitlab::Ci::Reports::TestCase.new( + name: 'addTest', + classname: 'CalculatorTest', + execution_time: 5.55, + status: Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS) + end + + def create_test_case_java_failed + Gitlab::Ci::Reports::TestCase.new( + name: 'subtractTest', + classname: 'CalculatorTest', + execution_time: 6.66, + system_output: sample_java_failed_message, + status: Gitlab::Ci::Reports::TestCase::STATUS_FAILED) + end + + def create_test_case_java_skipped + Gitlab::Ci::Reports::TestCase.new( + name: 'multiplyTest', + classname: 'CalculatorTest', + execution_time: 7.77, + status: Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED) + end + + def create_test_case_java_error + Gitlab::Ci::Reports::TestCase.new( + name: 'divideTest', + classname: 'CalculatorTest', + execution_time: 8.88, + status: Gitlab::Ci::Reports::TestCase::STATUS_ERROR) + end + + def sample_java_failed_message + <<-EOF.strip_heredoc + junit.framework.AssertionFailedError: expected:<1> but was:<3> + at CalculatorTest.subtractExpression(Unknown Source) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + EOF + end +end |