Hello Jeanne,
thanks a lot for your quick response..my apologies the example i gave above it was mainly to describe the scenario of my issue as i thought it was the return type issue. Please see the method which i want to carry out unit test for below:
My issue is that i don't know how to mock the boolean variable isUserValid? The variable isUserValid returns a boolean whereas my method validateViewLogin above returns a type ModelAndView. Basically i was trying to mock the isUserValid to return true so as to test the flow when the user is valid.
I was planning a unit test as shown below:
My assert will be if user validation is successful page login will be displayed
When i run my unit test i get this error message:
I know i am getting this error because
returns a boolean and my method expecting ModelAndView.How can i solve this to be able to carry out my unit test
.
Any advice please?
This is my controller to validate a user when submitting a form with username, password and i am using spring framework.
thanks in advance