Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JUnit giving null pointer exception but temp variable fixes exception  RSS feed

 
Gulshan Singh
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The relevant code is:


All variables used have been initialized; that's not the problem.
This test gives me a null pointer exception at the first verify line:


But this test works:


Why does the second test work?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37222
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you already got an answer on StackOverflow. Cross posting is fine although we do recommend you link between the posts so people know when it has been answered.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!