views:

92

answers:

2

What are Mock objects? Can you please explain the concept? How to make use of Mock objects in C++? Any source examples will be highly helpful.

+2  A: 

Read up on mockcpp and you'll find the answers to your question. Mocks are great for testing purposes where you can focus on testing one thing and mocking the behavior of other pieces in the environment.

Anon
+2  A: 

Hi,

In general, a mock object is referring to an instance of a class that as the name says "mocks" the functionality of the original class. This is usually simplified when coding against an interface, so when testing a component that depends on an interface, you simply implement the interface to return the results necessary to perform your tests.

You can find more information here, including the different kinds of mocks that are used for testing:

I hope this helps.

Thanks, Damian

Damian Schenkelman
@Damian +1 Thanks! Wish could accept 2 correct answers!
Als
@Als: no problem :), just glad I could help
Damian Schenkelman