Enterprise testing
SpringBootTest
Load application context. Source-reviewed example or artifact, NOT RUN.
Formal Syntax & Structure
java syntaxjava
@SpringBootTestWorking Example
Example Snippetjava
package lab;import org.junit.jupiter.api.Test;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.test.context.SpringBootTest;import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;import org.springframework.test.web.servlet.MockMvc;import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;@SpringBootTest@AutoConfigureMockMvcclass CatalogContextTest { @Autowired MockMvc mvc; @Test void realServiceBoundary() throws Exception { mvc.perform(get("/items/pen").header("X-Lab-Tenant", "alpha")) .andExpect(status().isOk()).andExpect(jsonPath("$.sku").value("pen")); mvc.perform(get("/items/pen").header("X-Lab-Tenant", "beta")) .andExpect(status().isNotFound()); }}