MockTracer implements Tracer { @Override public Span activeSpan() { return this.scopeManager.activeSpan(); } MockTracer();  MockTracer(ScopeManager scopeManager);  MockTracer(ScopeManager scopeManager, Propagator propagator);  MockTracer(Propagator propagator); synchronized void reset(); synchronized List<MockSpan> finishedSpans(); synchronized Map<String, Map<String, MockSpan>> finishedTraces(); @Override ScopeManager scopeManager(); @Override SpanBuilder buildSpan(String operationName); @Override void inject(SpanContext spanContext, Format<C> format, C carrier); @Override SpanContext extract(Format<C> format, C carrier); @Override Span activeSpan(); @Override Scope activateSpan(Span span); @Override synchronized void close();  }
@Test public void testActiveSpan() { MockTracer mockTracer = new MockTracer(); Assert.assertNull(mockTracer.activeSpan()); Span span = mockTracer.buildSpan("foo").start(); try (Scope scope = mockTracer.activateSpan(span)) { Assert.assertEquals(mockTracer.scopeManager().activeSpan(), mockTracer.activeSpan()); } Assert.assertNull(mockTracer.activeSpan()); Assert.assertTrue(mockTracer.finishedSpans().isEmpty()); }