خرید بک لینک

Vote count: 0

I am trying to test a get request for a rest api i am building. I want to test the response has x number of replies.

Now eventually this would be coected to a database so I would like to have dummy data that would be used for the test.

This is what I have so far, and as you can see the hasSize(2) is the comparison.

mockMvc.perform(get("/all")) .andExpect(status().isOk()) .andExpect( content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$", hasSize(2)));

Currently I have a hardcoded collection with two entries, but as I say it will eventually be coected to a database so the number of entries will change in development.

What is the best approach to imitate a the data that would be retued? Does spring and mockito have anything that can assist in this type of testing of api's?

asked 1 min ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 2 اسفند 1394 ساعت: 0:03

صفحه بندی