January 2018
Intermediate to advanced
414 pages
10h 29m
English
Let's go back to our previous test, where we tested our CustomerController in our CustomerControllerTest class, and let's review our /customers test:
@Testfun `we should GET a list of customers`() { mockMvc.perform(get("/customers")) .andExpect(status().isOk) .andExpect(jsonPath("\$").isArray) .andExpect(jsonPath("\$[0].id").value(1)) .andExpect(jsonPath("\$[0].name").value("Kotlin")) .andExpect(jsonPath("\$[1].id").value(2)) .andExpect(jsonPath("\$[1].name").value("Spring")) .andExpect(jsonPath("\$[2].id").value(3)) .andExpect(jsonPath("\$[2].name").value("Microservice")) .andDo(print())}
Imagine that our customers are actually behind a database—a database that may be modified externally or outside of our tests—then our test ...
Read now
Unlock full access