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
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