Class: Datadog::CI::Test
Overview
Represents a single part of a test run.
Instance Attribute Summary
Attributes inherited from Span
Instance Method Summary collapse
-
#failed!(exception: nil) ⇒ void
Sets the status of the span to “fail”.
-
#finish ⇒ void
Finishes the current test.
-
#name ⇒ String
The name of the test.
-
#passed! ⇒ void
Sets the status of the span to “pass”.
-
#set_parameters(arguments, metadata = {}) ⇒ void
Sets the parameters for this test (e.g. Cucumber example or RSpec shared specs).
-
#skipped!(exception: nil, reason: nil) ⇒ void
Sets the status of the span to “skip”.
-
#source_file ⇒ String?
Source file path of the test relative to git repository root.
-
#test_module_id ⇒ String
Span id of the running test module this test belongs to.
-
#test_session_id ⇒ String
Span id of the running test session this test belongs to.
-
#test_suite ⇒ Datadog::CI::TestSuite?
Running test suite that this test is part of (if any).
-
#test_suite_id ⇒ String
Span id of the running test suite this test belongs to.
-
#test_suite_name ⇒ String
Name of the running test suite this test belongs to.
Methods inherited from Span
#failed?, #get_tag, #id, #initialize, #passed?, #service, #set_default_tags, #set_environment_runtime_tags, #set_metric, #set_tag, #set_tags, #skipped?, #to_s, #type, #undefined?
Constructor Details
This class inherits a constructor from Datadog::CI::Span
Instance Method Details
#failed!(exception: nil) ⇒ void
This method returns an undefined value.
Sets the status of the span to “fail”.
76 77 78 79 80 |
# File 'lib/datadog/ci/test.rb', line 76 def failed!(exception: nil) super record_test_result(Ext::Test::Status::FAIL) end |
#finish ⇒ void
This method returns an undefined value.
Finishes the current test.
20 21 22 23 24 |
# File 'lib/datadog/ci/test.rb', line 20 def finish super recorder.deactivate_test end |
#name ⇒ String
Returns the name of the test.
14 15 16 |
# File 'lib/datadog/ci/test.rb', line 14 def name get_tag(Ext::Test::TAG_NAME) end |
#passed! ⇒ void
This method returns an undefined value.
Sets the status of the span to “pass”.
67 68 69 70 71 |
# File 'lib/datadog/ci/test.rb', line 67 def passed! super record_test_result(Ext::Test::Status::PASS) end |
#set_parameters(arguments, metadata = {}) ⇒ void
This method returns an undefined value.
Sets the parameters for this test (e.g. Cucumber example or RSpec shared specs). Parameters are needed to compute test fingerprint to distinguish between different tests having same names.
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/datadog/ci/test.rb', line 98 def set_parameters(arguments, = {}) return if arguments.nil? set_tag( Ext::Test::TAG_PARAMETERS, JSON.generate( { arguments: arguments, metadata: } ) ) end |
#skipped!(exception: nil, reason: nil) ⇒ void
This method returns an undefined value.
Sets the status of the span to “skip”.
86 87 88 89 90 |
# File 'lib/datadog/ci/test.rb', line 86 def skipped!(exception: nil, reason: nil) super record_test_result(Ext::Test::Status::SKIP) end |
#source_file ⇒ String?
Source file path of the test relative to git repository root.
61 62 63 |
# File 'lib/datadog/ci/test.rb', line 61 def source_file get_tag(Ext::Test::TAG_SOURCE_FILE) end |
#test_module_id ⇒ String
Span id of the running test module this test belongs to.
48 49 50 |
# File 'lib/datadog/ci/test.rb', line 48 def test_module_id get_tag(Ext::Test::TAG_TEST_MODULE_ID) end |
#test_session_id ⇒ String
Span id of the running test session this test belongs to.
54 55 56 |
# File 'lib/datadog/ci/test.rb', line 54 def test_session_id get_tag(Ext::Test::TAG_TEST_SESSION_ID) end |
#test_suite ⇒ Datadog::CI::TestSuite?
Running test suite that this test is part of (if any).
29 30 31 32 |
# File 'lib/datadog/ci/test.rb', line 29 def test_suite suite_name = test_suite_name CI.active_test_suite(suite_name) if suite_name end |
#test_suite_id ⇒ String
Span id of the running test suite this test belongs to.
36 37 38 |
# File 'lib/datadog/ci/test.rb', line 36 def test_suite_id get_tag(Ext::Test::TAG_TEST_SUITE_ID) end |