Josimar Lopes
Josimar Lopes

Reputation: 156

JUnit Test method with HttpSession object in spring boot

I'm trying to test a method that accepts a session object as a parameter and returns boolean according to certain conditions.

My question is: How can I pass a non-null session object to my method in JUnit test (using spring boot)?

I have tried several methods but I keep getting java.lang.NullPointerException errors.

Upvotes: 0

Views: 721

Answers (1)

Josimar Lopes
Josimar Lopes

Reputation: 156

I was a victim of slf4j - IllegalAccessError errors, whenever I ran the test it kept giving me random errors but this was the most consistent. I had to debug the issue in my classpath, pom and found out that the culprit was library dependencies, an old version of slf4j was being used instead of the one I set in pom.xml.

After removing and rebuilding the module, the test errors cleared.

Thanks.

Upvotes: 1

Related Questions