userinfo is a class which contains informations about the user and set in session scope when the user logged in.but when I try the test :
The problem is the userinfo class attribute is set in another method so when i try to access it in this method i got a NullPointerException , and with Autowiring the httpSession i got a new Session for each method i have to test.
What should i do with the session attribute, my method doesn't accept a session parameter , and for each test it create a WebApplicationContext with a new session.
My first advice is don't autowire in the session like that and get rid of those nasty _ in your variable names If you need the whole session spring will provide it in the method arguments. Take a look at the following post for how to use mock sessions (look at the last answer not the accepted answer)