1
Creep
4y

How would you java spring guys write a JUnit test for a login controller? My controller works as followin: It checks the username and password values from the model and then either redirects to the home page or redirects to the login page with an error code. How am I supposed to test that behavior, when MvcMock can't capture the redirects?

Comments
  • 0
    I don't test controllers. Controllers are to be as simple as it gets. Sprung does the rest. The most I can test is whether my logic in fact gives a command to Spring to issue a 302. This logic should be in a separate method that I could test.

    I don't need to test whether thebredirect happens. It's spring's job to make it happen and I assume it's working. My job is to ensure I am giving Spring a command to do that
Add Comment