title: How to init a default trace context with span in controller when using SpringBootTest
body: <p>I'm making a move from Spring Boot 1.5.21 to 2.2.5, and in the process also moving from spring-boot-cloud version Edgware.SR6 to Hoxton.SR3. This move forced me to ditch the sleuth's own implementation of tracer/span model and embrace the new model from brave. However, I have an issue with my controller integration tests.</p>
  
  <p>I have a microservice called <code>Edge</code> with a main class called <code>EdgeApplication</code> and I'm using Spock as a testing framework.
  My code includes the following test class:</p>
  
  <pre><code>@ContextConfiguration(classes = EdgeApplication.class)
  @SpringBootTest(classes = EdgeApplication.class)
  @ActiveProfiles(profiles = ["test"])
  @AutoConfigureMockMvc
  class VerificationCodeControllerSpecIT extends Specification {
  
    @Autowired
    MockMvc mockMvc
  
    def setup() {
       mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build()
    }
  
    def "Generate change password verification code"() {
      // Some code calling a PrincipalController via mockMvc.perform()
    }
  }
  </code></pre>
  
  <p>Previously, in Spring Boot 1.5.21, when The call got to the <code>PrincipalController</code>, a default trace context with span was initialized. Now, in Spring Boot 2, this is not the case. I must emphasise that this lack of context in the <code>PrincipalController</code> only happens in test code, and not in a real run of the microservice.</p>
  
  <p>Why this behavior changed and how can I restore the old behavior, i.e. have a default trace context with span when the controller is called?</p>
  
  <p>I added a demo project:
  <a href="https://github.com/eyalrin/spring-cloud-sleuth-tracing-demo" rel="nofollow noreferrer">Demo</a>
  You will be able to run the integration test and in debug see that in the controller <code>tracer.currentSpan()</code> is null (while containing a value on normal project run)</p>