Skip to content

Commit

Permalink
[minitest] remove test suite prefix from the test name
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Jan 16, 2024
1 parent 51feb0e commit 00d39f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
4 changes: 1 addition & 3 deletions lib/datadog/ci/contrib/minitest/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def before_setup
super
return unless datadog_configuration[:enabled]

test_name = "#{class_name}##{name}"

test_suite_name = Helpers.test_suite_name(self.class, name)
if Helpers.parallel?(self.class)
test_suite_name = "#{test_suite_name} (#{name} concurrently)"
Expand All @@ -27,7 +25,7 @@ def before_setup
source_file, line_number = method(name).source_location

CI.start_test(
test_name,
name,
test_suite_name,
tags: {
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
Expand Down
28 changes: 14 additions & 14 deletions spec/datadog/ci/contrib/minitest/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def test_foo
klass.new(:test_foo).run

expect(span.type).to eq(Datadog::CI::Ext::AppTypes::TYPE_TEST)
expect(span.name).to eq("SomeTest#test_foo")
expect(span.resource).to eq("SomeTest#test_foo")
expect(span.name).to eq("test_foo")
expect(span.resource).to eq("test_foo")
expect(span.service).to eq("ltest")
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_NAME)).to eq("SomeTest#test_foo")
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_NAME)).to eq("test_foo")
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_SUITE)).to eq(
"SomeTest at spec/datadog/ci/contrib/minitest/instrumentation_spec.rb"
)
Expand Down Expand Up @@ -110,9 +110,9 @@ def self.name
klass.new(method_name).run

expect(span.type).to eq(Datadog::CI::Ext::AppTypes::TYPE_TEST)
expect(span.resource).to eq("SomeSpec##{method_name}")
expect(span.resource).to eq(method_name)
expect(span.service).to eq("ltest")
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_NAME)).to eq("SomeSpec##{method_name}")
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_NAME)).to eq(method_name)
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_SUITE)).to eq(
"SomeSpec at spec/datadog/ci/contrib/minitest/instrumentation_spec.rb"
)
Expand Down Expand Up @@ -514,7 +514,7 @@ def test_fail
end

it "traces test, test session, test module with failed status" do
expect(first_test_span.get_tag(Datadog::CI::Ext::Test::TAG_NAME)).to eq("SomeFailedTest#test_fail")
expect(first_test_span.get_tag(Datadog::CI::Ext::Test::TAG_NAME)).to eq("test_fail")
expect(first_test_span.get_tag(Datadog::CI::Ext::Test::TAG_STATUS)).to eq(
Datadog::CI::Ext::Test::Status::FAIL
)
Expand Down Expand Up @@ -561,10 +561,10 @@ class SomeSpec < Minitest::Spec

expect(test_names).to eq(
[
"SomeSpec#test_0001_does not fail",
"in context#test_0001_does not fail",
"in context::deeper context#test_0001_does not fail",
"in other context#test_0001_does not fail"
"test_0001_does not fail",
"test_0001_does not fail",
"test_0001_does not fail",
"test_0001_does not fail"
]
)
end
Expand Down Expand Up @@ -635,10 +635,10 @@ def test_b_2
test_names = test_spans.map { |span| span.get_tag(Datadog::CI::Ext::Test::TAG_NAME) }.sort
expect(test_names).to eq(
[
"TestA#test_a_1",
"TestA#test_a_2",
"TestB#test_b_1",
"TestB#test_b_2"
"test_a_1",
"test_a_2",
"test_b_1",
"test_b_2"
]
)

Expand Down

0 comments on commit 00d39f0

Please sign in to comment.