aspose file tools*
The moose likes Testing and the fly likes JUnit giving null pointer exception but temp variable fixes exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit giving null pointer exception but temp variable fixes exception" Watch "JUnit giving null pointer exception but temp variable fixes exception" New topic
Author

JUnit giving null pointer exception but temp variable fixes exception

Gulshan Singh
Ranch Hand

Joined: Apr 22, 2009
Posts: 41
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29249
    
139

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JUnit giving null pointer exception but temp variable fixes exception
 
Similar Threads
Please go thru the code
HashMap and HashSet
hashCode & HashMap doubts
adding objects with same hashcodes and true value return by equals() method to a set.
Mockito Help - Problem to sort a List of mock objects.