From 00d39f02993326ebbec85cdc42e6935c71871423 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Tue, 16 Jan 2024 16:39:15 +0100 Subject: [PATCH] [minitest] remove test suite prefix from the test name --- lib/datadog/ci/contrib/minitest/hooks.rb | 4 +-- .../contrib/minitest/instrumentation_spec.rb | 28 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/datadog/ci/contrib/minitest/hooks.rb b/lib/datadog/ci/contrib/minitest/hooks.rb index 84a4c07f..c635c0ab 100644 --- a/lib/datadog/ci/contrib/minitest/hooks.rb +++ b/lib/datadog/ci/contrib/minitest/hooks.rb @@ -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)" @@ -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, diff --git a/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb index 623d0edf..1cc5e773 100644 --- a/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb @@ -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" ) @@ -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" ) @@ -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 ) @@ -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 @@ -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" ] )