<@U6ZRXK1KL> i’m not sure why your code is not wor...
# spring
l
@ander.dev i’m not sure why your code is not working, but i just tried a simple test and it worked. the code is like:
Copy code
@RestController
@RequestMapping("/api/books")
class BookController {

    @GetMapping
    fun getAll(): List<Book> {
        return listOf(
                Book("1", "Bootiful"),
                Book("2", "Spring")
        )
    }
}

data class Book(
        val id: String?,
        val name: String
)

@RunWith(SpringRunner::class)
@WebMvcTest(BookController::class)
class BookControllerTest {

    @Autowired
    lateinit var mvc: MockMvc

    @Test
    fun getAllShouldReturnBooks() {
        this.mvc.perform(get("/api/books").accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk)
    }
}