Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Is this Mock Object Approach too complex?

Thread Tools

Is this Mock Object Approach too complex?

Posts: n/a
Hi. I was just reading an article about a novel way of implementing
mock objects using an anonymous inner class. The article is at:

I find, though, that when I try to run the sample code in listings 5
and 6 through JUnit, I get a null pointer error.

So now I'm wondering two things:

1- Does anyone see why this code wouldn't work?

2- Does this approach to Mock classes add unnecessary complexity?
Perhaps I'd just be better off using a regular ol' derived class
instead of an anonymous inner class. The catch is that the regular
ol' derived class would need to be passed into the class being tested
as a constructor parameter instead of being contained completely by
the class being tested.

Any thoughts?


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need recommendations on mock object packages Matthew Wilson Python 1 10-18-2007 03:36 AM
rmock mock object only returns default value mfaine Java 0 08-23-2007 04:05 PM
"Virtual" file system mock object - replacing stuff in __builtins__ Remy Blank Python 3 03-06-2004 12:20 AM
problem with closure arguments and *args in mock object John J. Lee Python 4 11-08-2003 12:28 PM
Mock object creation by example? John J. Lee Python 0 07-08-2003 11:27 PM