Is this Mock Object Approach too complex?

K

Ken

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

http://www-106.ibm.com/developerworks/library/j-mocktest.html

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?

Thanks,

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top