Mock object...

Posted on 2006-03-21
Last Modified: 2008-03-03
Hi experts,

    Does anyone know if I can cast a mock object to another class ? If so, how to do that ? thanks.
Question by:meow00
    LVL 92

    Accepted Solution

    wouldn't think so, would be more a case of casting whatever it is proxying.
    what sort of mock objects are you using?
    LVL 8

    Assisted Solution

    LVL 92

    Expert Comment

    For example if using jmock you would cast the object returned by proxy() method to whatever class it is you are mocking.
    LVL 24

    Expert Comment

    Most mocking uses interfaces for this reason.
    Your reference should be to that interface.

    There are some mocking frameworks that work on classes, but they're limited in functionality.


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now