Spring MVC controller Test - print the result JSON String

前端 未结 5 2225
一向
一向 2021-01-30 05:03

Hi I have a Spring mvc controller

@RequestMapping(value = \"/jobsdetails/{userId}\", method = RequestMethod.GET)
@ResponseBody
public List jobsDetai         


        
5条回答
  •  耶瑟儿~
    2021-01-30 05:32

    You can enable printing response of each test method when setting up the MockMvc instance.

    springMvc = MockMvcBuilders.webAppContextSetup(wContext)
                   .alwaysDo(MockMvcResultHandlers.print())
                   .build();
    

    Notice the .alwaysDo(MockMvcResultHandlers.print()) part of the above code. This way you can avoid applying print handler for each test method.

提交回复
热议问题