Class: Datadog::CI::TestSession

Inherits:
ConcurrentSpan show all
Defined in:
lib/datadog/ci/test_session.rb

Overview

Represents the whole test session process. Documentation on test sessions is here: https://docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#sessions This object can be shared between multiple threads.

Instance Attribute Summary

Attributes inherited from Span

#tracer_span

Instance Method Summary collapse

Methods inherited from ConcurrentSpan

#get_tag, #initialize, #set_metric, #set_tag, #set_tags, #synchronize

Methods inherited from Span

#clear_tag, #failed!, #failed?, #get_tag, #git_branch, #git_commit_sha, #git_repository_url, #id, #initialize, #os_architecture, #os_platform, #os_version, #passed!, #passed?, #runtime_name, #runtime_version, #service, #set_default_tags, #set_environment_runtime_tags, #set_metric, #set_tag, #set_tags, #skipped!, #skipped?, #to_s, #trace_id, #type, #undefined?

Constructor Details

This class inherits a constructor from Datadog::CI::ConcurrentSpan

Instance Method Details

#code_coverage?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/datadog/ci/test_session.rb', line 33

def code_coverage?
  get_tag(Ext::Test::TAG_CODE_COVERAGE_ENABLED) == "true"
end

#finishvoid

This method returns an undefined value.

Finishes the current test session.



17
18
19
20
21
# File 'lib/datadog/ci/test_session.rb', line 17

def finish
  test_visibility.deactivate_test_session

  super
end

#inheritable_tagsHash

Return the test session tags that could be inherited by sub-spans

Returns:

  • (Hash)

    the tags to be inherited by sub-spans.



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/datadog/ci/test_session.rb', line 39

def inheritable_tags
  return @inheritable_tags if defined?(@inheritable_tags)

  # this method is not synchronized because it does not iterate over the tags collection, but rather
  # uses synchronized method #get_tag to get each tag value
  res = {}
  Ext::Test::INHERITABLE_TAGS.each do |tag|
    res[tag] = get_tag(tag)
  end
  @inheritable_tags = res.freeze
end

#nameString

Return the test session's name which is equal to test command used

Returns:

  • (String)

    the command for this test session.



25
26
27
# File 'lib/datadog/ci/test_session.rb', line 25

def name
  get_tag(Ext::Test::TAG_COMMAND)
end

#skipping_tests?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/datadog/ci/test_session.rb', line 29

def skipping_tests?
  get_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_ENABLED) == "true"
end