This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Testing and the fly likes EasyMock 3.0 Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "EasyMock 3.0 Question" Watch "EasyMock 3.0 Question" New topic
Author

EasyMock 3.0 Question

Jeff Palmer
Greenhorn

Joined: Feb 14, 2011
Posts: 1
I'm trying to use EasyMock 3.0 to test a MessageListener class that I wrote. When I run my test, I'm consistently getting a NPE for a class that I'm mocking.

The code for the method I'm trying to test is as follows (the NPE is happening at line 07 in the following code):



My test code is as follows:



I'm fairly new to EasyMock so any help would be greatly appreciated. Thanks!
Krisztian Milesz
Greenhorn

Joined: Mar 02, 2008
Posts: 5
It seems like that you've just created a mock MessageUtility but you didn't inject that into the listener object. You have to tell the listener to use your mocked MessageUtility.

Regards,
Krisztian
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: EasyMock 3.0 Question
 
Similar Threads
Unable to understand : No Last Call on a Mock available. _ Easy Mocks
powermock : ProcessBuilder redirectErrorStream giving nullPointerException
junit + struts2 application
Help: problem with EasyMock
Easy mock class intantiation