Skip to content

Commit

Permalink
Fix within/exclude patterns in mocks
Browse files Browse the repository at this point in the history
Flag incorrect tests for looking into
  • Loading branch information
Marko Elezovic committed Jun 11, 2022
1 parent 0cd3a7b commit f03f500
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ 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)

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])
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f03f500

Please sign in to comment.