This application
@SpringBootApplication
public class TracertestApplication {
public static void main(String[] args) {
SpringApplication.run(TracertestApplication.class, args);
}
@Bean
CommandLineRunner clr(Tracer tracer) {
return (args) -> System.out.println(tracer);
}
}
with this test
@SpringBootTest
class TracertestApplicationTests {
@Test
void contextLoads() {
}
}
fails:
Parameter 0 of method clr in com.example.tracertest.TracertestApplication required a bean of type 'io.micrometer.tracing.Tracer' that could not be found.
We disable tracing in tests, which means there is no Tracer bean available. We disable metrics too, but we provide a SimpleMeterRegistry for the MeterRegistry.
Marcin has added a NOOP tracer which we should use as a Tracer in tests when tracing is not enabled. With this change, the test works again.
Comment From: mhalbritter
Here are the changes needed: https://github.com/mhalbritter/spring-boot/commit/c0fe55e186ac3a02c4c6d244d5bd6d9e02b3953c (needs Micrometer Tracing Snapshots)