1. 在c#中,测试http的,一般做一个mock的httpContext, 然后里面的request和response都使用mock的,这样设置好后,就可以测试controller
2. 在java中,因为是httpservelet这些,所以实例化测试创建mock的httprequest这些
https://www.baeldung.com/java-httpservletrequest-mock
@Test void givenHttpServletRequest_whenUsingMockHttpServletRequest_thenReturnsParameterValues() throws IOException { MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("firstName", "Spring"); request.setParameter("lastName", "Test"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.doGet(request, response); assertThat(response.getContentAsString()).isEqualTo("Full Name: Spring Test"); }
标签:java,C#,request,Test,http,response,mock From: https://www.cnblogs.com/hualiu0/p/17768842.html