From f03f50084dd86a9ae1020ccbe804aa46e52a4796 Mon Sep 17 00:00:00 2001 From: Marko Elezovic Date: Sat, 11 Jun 2022 23:49:20 +0200 Subject: [PATCH] Fix within/exclude patterns in mocks Flag incorrect tests for looking into --- .../test/scala/kanela/agent/InstrumentationLoaderSpec.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/agent/src/test/scala/kanela/agent/InstrumentationLoaderSpec.scala b/agent/src/test/scala/kanela/agent/InstrumentationLoaderSpec.scala index 9195a3b..a5713e7 100644 --- a/agent/src/test/scala/kanela/agent/InstrumentationLoaderSpec.scala +++ b/agent/src/test/scala/kanela/agent/InstrumentationLoaderSpec.scala @@ -41,6 +41,7 @@ class InstrumentationLoaderSpec extends FlatSpec with Matchers with BeforeAndAft when(agentModuleDescriptionMock.getInstrumentations).thenReturn(JList.empty[String]()) when(agentModuleDescriptionMock.getWithinPackage).thenReturn("") + when(agentModuleDescriptionMock.getExcludePackage).thenReturn("") when(agentModuleDescriptionMock.getName).thenReturn("x-module") InstrumentationLoader.load(instrumentationMock, Thread.currentThread().getContextClassLoader, agentConfiguration) @@ -48,6 +49,9 @@ class InstrumentationLoaderSpec extends FlatSpec with Matchers with BeforeAndAft verify(agentConfiguration, times(1)).getAgentModules } + // TODO FIXME: This test is useless since it explodes before getting to InstrumentationLoader.load + // It should be refactored to expect a specific exception and not a generic RuntimeException + // (currently blowing up due to errorneous spy+mock combo) "with an unknown instrumentation" should "blow up" in { val instrumentationMock = mock(classOf[Instrumentation]) val agentModuleDescriptionMock = mock(classOf[ModuleConfiguration]) @@ -81,6 +85,7 @@ class InstrumentationLoaderSpec extends FlatSpec with Matchers with BeforeAndAft when(agentModuleDescriptionMock.getInstrumentations).thenReturn(JList.of[String]("kanela.agent.instrumentation.KamonFakeInstrumentationBuilder")) when(agentModuleDescriptionMock.getWithinPackage).thenReturn("") + when(agentModuleDescriptionMock.getExcludePackage).thenReturn("") when(agentModuleDescriptionMock.getName).thenReturn("x-module") InstrumentationLoader.load(instrumentationMock, Thread.currentThread().getContextClassLoader, agentConfiguration)