We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Mock object...

meow00 asked
Medium Priority
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.
Watch Question

Java Developer
Top Expert 2010
wouldn't think so, would be more a case of casting whatever it is proxying.
what sort of mock objects are you using?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Mick BarryJava Developer
Top Expert 2010

For example if using jmock you would cast the object returned by proxy() method to whatever class it is you are mocking.
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.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.