Mock Objects

Business Agility Office

A technique commonly used in the context of crafting automated unit tests. It consists of instantiating a test-specific version of a software component (typically a class), which insteads of the normal behaviors provides precomputed results, and often also checks that it’s invoked as expected by the objects being tested.

For instance, the “mock” version of a database component will a) provide “canned” answers to database queries, instead of connecting to a real live database, and b) verify that the database is being accessed in the manner expected and stipulated in the test.

« Back to Glossary Index