Spring Boot In Action
TEST - Catálogo BURRF
Spring Boot In Action   

Spring Boot In Action < 2026 Edition >

Add dependency:

@SpringBootTest @AutoConfigureMockMvc class BookControllerTest @Autowired private MockMvc mockMvc; Spring Boot In Action

@Test void shouldCreateBook() throws Exception mockMvc.perform(post("/api/books") .contentType(MediaType.APPLICATION_JSON) .content("\"title\":\"Spring Boot in Action\",\"author\":\"Craig Walls\"")) .andExpect(status().isOk()); \"author\":\"Craig Walls\"")) .andExpect(status().isOk())

management.endpoints.web.exposure.include=health,info,metrics Build a fat JAR: public Book saveBook(Book book) return bookRepo.save(book)

./mvnw package

@Service @RequiredArgsConstructor public class BookService private final BookRepository bookRepo; public Book saveBook(Book book) return bookRepo.save(book);