debian-mirror-gitlab/spec/support/helpers/test_reports_helper.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

104 lines
3.4 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-11-18 11:00:15 +05:30
module TestReportsHelper
2019-09-30 21:07:59 +05:30
def create_test_case_rspec_success(name = 'test_spec')
2018-11-18 11:00:15 +05:30
Gitlab::Ci::Reports::TestCase.new(
2021-01-03 14:25:43 +05:30
suite_name: 'rspec',
2018-11-18 11:00:15 +05:30
name: 'Test#sum when a is 1 and b is 3 returns summary',
2019-09-30 21:07:59 +05:30
classname: "spec.#{name}",
2018-11-18 11:00:15 +05:30
file: './spec/test_spec.rb',
execution_time: 1.11,
status: Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
end
2020-11-24 15:15:51 +05:30
def create_test_case_rspec_failed(name = 'test_spec', execution_time = 2.22)
2018-11-18 11:00:15 +05:30
Gitlab::Ci::Reports::TestCase.new(
2021-01-03 14:25:43 +05:30
suite_name: 'rspec',
2019-09-30 21:07:59 +05:30
name: 'Test#sum when a is 1 and b is 3 returns summary',
classname: "spec.#{name}",
2018-11-18 11:00:15 +05:30
file: './spec/test_spec.rb',
2020-11-24 15:15:51 +05:30
execution_time: execution_time,
2018-11-18 11:00:15 +05:30
system_output: sample_rspec_failed_message,
status: Gitlab::Ci::Reports::TestCase::STATUS_FAILED)
end
2019-09-30 21:07:59 +05:30
def create_test_case_rspec_skipped(name = 'test_spec')
2018-11-18 11:00:15 +05:30
Gitlab::Ci::Reports::TestCase.new(
2021-01-03 14:25:43 +05:30
suite_name: 'rspec',
2018-11-18 11:00:15 +05:30
name: 'Test#sum when a is 3 and b is 3 returns summary',
2019-09-30 21:07:59 +05:30
classname: "spec.#{name}",
2018-11-18 11:00:15 +05:30
file: './spec/test_spec.rb',
execution_time: 3.33,
status: Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED)
end
2019-09-30 21:07:59 +05:30
def create_test_case_rspec_error(name = 'test_spec')
2018-11-18 11:00:15 +05:30
Gitlab::Ci::Reports::TestCase.new(
2021-01-03 14:25:43 +05:30
suite_name: 'rspec',
2018-11-18 11:00:15 +05:30
name: 'Test#sum when a is 4 and b is 4 returns summary',
2019-09-30 21:07:59 +05:30
classname: "spec.#{name}",
2018-11-18 11:00:15 +05:30
file: './spec/test_spec.rb',
execution_time: 4.44,
status: Gitlab::Ci::Reports::TestCase::STATUS_ERROR)
end
def sample_rspec_failed_message
2023-06-20 00:43:36 +05:30
<<-TEST_REPORT_MESSAGE.strip_heredoc
2018-11-18 11:00:15 +05:30
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;
2023-06-20 00:43:36 +05:30
TEST_REPORT_MESSAGE
2018-11-18 11:00:15 +05:30
end
2019-09-30 21:07:59 +05:30
def create_test_case_java_success(name = 'addTest')
2018-11-18 11:00:15 +05:30
Gitlab::Ci::Reports::TestCase.new(
2021-01-03 14:25:43 +05:30
suite_name: 'java',
2019-09-30 21:07:59 +05:30
name: name,
2018-11-18 11:00:15 +05:30
classname: 'CalculatorTest',
execution_time: 5.55,
status: Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
end
2019-09-30 21:07:59 +05:30
def create_test_case_java_failed(name = 'addTest')
2018-11-18 11:00:15 +05:30
Gitlab::Ci::Reports::TestCase.new(
2021-01-03 14:25:43 +05:30
suite_name: 'java',
2019-09-30 21:07:59 +05:30
name: name,
2018-11-18 11:00:15 +05:30
classname: 'CalculatorTest',
execution_time: 6.66,
system_output: sample_java_failed_message,
status: Gitlab::Ci::Reports::TestCase::STATUS_FAILED)
end
2019-09-30 21:07:59 +05:30
def create_test_case_java_skipped(name = 'addTest')
2018-11-18 11:00:15 +05:30
Gitlab::Ci::Reports::TestCase.new(
2021-01-03 14:25:43 +05:30
suite_name: 'java',
2019-09-30 21:07:59 +05:30
name: name,
2018-11-18 11:00:15 +05:30
classname: 'CalculatorTest',
execution_time: 7.77,
status: Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED)
end
2019-09-30 21:07:59 +05:30
def create_test_case_java_error(name = 'addTest')
2018-11-18 11:00:15 +05:30
Gitlab::Ci::Reports::TestCase.new(
2021-01-03 14:25:43 +05:30
suite_name: 'java',
2019-09-30 21:07:59 +05:30
name: name,
2018-11-18 11:00:15 +05:30
classname: 'CalculatorTest',
execution_time: 8.88,
status: Gitlab::Ci::Reports::TestCase::STATUS_ERROR)
end
def sample_java_failed_message
2023-06-20 00:43:36 +05:30
<<-TEST_REPORT_MESSAGE.strip_heredoc
2018-11-18 11:00:15 +05:30
junit.framework.AssertionFailedError: expected:&lt;1&gt; but was:&lt;3&gt;
at CalculatorTest.subtractExpression(Unknown Source)
2021-12-11 22:18:48 +05:30
at java.base/jdk.internal.database.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.database.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.database.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2023-06-20 00:43:36 +05:30
TEST_REPORT_MESSAGE
2018-11-18 11:00:15 +05:30
end
end