Mocks

Mocks image
In testing, a mock is a simulated object that mimics the behavior of a real object - we use mock in cases where we need to test something that requires a feature that is not yet available, so we simulate it. 

Mocks are used to isolate the code under test from its dependencies, such as databases, APIs, or other classes. 

By using mocks, you can control the inputs to the code being tested and verify how it interacts with its dependencies. This makes tests more reliable and easier to write. 

For example, if you're testing a function that interacts with a database, you could use a mock database object to simulate the database's behavior without actually connecting to a real database. 
RiskStorming image
An educational tool to explore Risk Analysis and Quality Strategy building with the whole team.
Explore MoT
TestBash Brighton 2025 image
Wed, 1 Oct
On the 1st & 2nd of October, 2025 we'll be back to Brighton for another TestBash: the largest software testing conference in the UK
MoT Foundation Certificate in Test Automation
Unlock the essential skills to transition into Test Automation through interactive, community-driven learning, backed by industry expertise
This Week in Testing
Debrief the week in Testing via a community radio show hosted by Simon Tomes and members of the community
Subscribe to our newsletter
We'll keep you up to date on all the testing trends.