@After public void afterMethod() { resetTracing(); }
@Before public void beforeMethod() { runnableMock = mock(Runnable.class); throwExceptionDuringCall = false; currentSpanStackWhenRunnableWasCalled = new ArrayList<>(); currentMdcInfoWhenRunnableWasCalled = new ArrayList<>(); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { currentSpanStackWhenRunnableWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy()); currentMdcInfoWhenRunnableWasCalled.add(MDC.getCopyOfContextMap()); if (throwExceptionDuringCall) throw new RuntimeException("kaboom"); return null; } }).when(runnableMock).run(); resetTracing(); }
runnableMock, spanStack, mdcInfo ); resetTracing(); assertThat(Tracer.getInstance().getCurrentSpanStackCopy()).isNull(); assertThat(MDC.getCopyOfContextMap()).isNullOrEmpty();