I am trying to create a web application using TDD, however, I am having a question about how to test the Servlet that processes the requests and calls the proper logic, I do not know how to do assert
.
@Test
public void deveCriarInstaciarUmObjetoActionPelaURI() throws ServletException, IOException {
Dispatcher dispatcher = new Dispatcher();
HttpServletRequest request = Mockito.mock( HttpServletRequest.class );
HttpServletResponse response = Mockito.mock( HttpServletResponse.class);
Mockito.when( request.getContextPath() ).thenReturn( "/app" );
Mockito.when( request.getRequestURI() ).thenReturn( "/app/controle/acao" );
dispatcher.service(request , response);
}
I would need to test if a Control object was created and called the action method, but I do not know how to do this test, any suggestions?