summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-08-03 18:39:48 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-08-03 18:39:48 +0000
commit99c033f2888a96267aa0443ad7a07f1f0e861992 (patch)
treea1d7bb68dfaba668987705538bfa4526c473010d /spec/support
parent53ecd2e147eb24f7e53385cb21f0c9759a482d6c (diff)
parentfafd1764ca71156d261a604d64b43d531667cb17 (diff)
downloadgitlab-ce-99c033f2888a96267aa0443ad7a07f1f0e861992.tar.gz
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.rb4
-rw-r--r--spec/support/test_reports/test_reports_helper.rb93
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 &lt;top (required)&gt;&apos;
+ 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:&lt;1&gt; but was:&lt;3&gt;
+ 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