Is this Mock Object Approach too complex?

Discussion in 'Java' started by Ken, Jul 16, 2004.

  1. Ken

    Ken Guest

    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
     
    Ken, Jul 16, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J. Lee

    Mock object creation by example?

    John J. Lee, Jul 9, 2003, in forum: Python
    Replies:
    0
    Views:
    482
    John J. Lee
    Jul 9, 2003
  2. John J. Lee
    Replies:
    4
    Views:
    373
    John J. Lee
    Nov 8, 2003
  3. Remy Blank
    Replies:
    3
    Views:
    906
    Lothar Scholz
    Mar 6, 2004
  4. vj
    Replies:
    0
    Views:
    280
  5. Replies:
    8
    Views:
    596
    Pavel Lepin
    Sep 13, 2007
Loading...

Share This Page