---
title: "What is the main difference between a stubs, a mock?"  
description: "What is the main difference between a stubs, a mock?"  
author: "Sanjay Goenka"  
published: 2022-04-06  
canonical: https://answers.mindstick.com/qa/96746/what-is-the-main-difference-between-a-stubs-a-mock  
category: "troubleshooting"  
tags: ["troubleshooting", "software engineering"]  
reading_time: 1 minute  

---

# What is the main difference between a stubs, a mock?

What is the main [difference](https://yourviews.mindstick.com/story/5016/chia-vs-basil-seeds-what-s-the-difference) between a [stubs](https://www.mindstick.com/interview/1275/what-are-stubs-and-drivers-used-for-in-white-box-testing), a [mock](https://yourviews.mindstick.com/view/82642/how-helpful-are-mock-test-and-test-series-at-mppsc-coaching-institutes)?

## Answers

### Answer by Hitesh Vohra

- A **stub** interface simulates an actual object by having a small number of methods. It's a type of object that has pre-existing data and always returns the same value regardless of the input. Furthermore, we mostly employ it when we don't want the real object to respond.
- The **mock** is an interface that we programme to compare the outputs from the tests to the expected outcomes. We frequently use third-party libraries such as Mockito and JMock to accomplish this. It's particularly useful when we're working with a large test suite and each test demands a different set of data.
- Stubs offer input for the application under test, allowing the test to be run on something other than the application under test.
- Mocks provide information to the test that helps it determine whether it should pass or fail.
- A stub is for the application, while a mock is for the test

\

**Read More: [What is mean by software scope?](https://answers.mindstick.com/qa/96747/what-is-mean-by-software-scope)**


---

Original Source: https://answers.mindstick.com/qa/96746/what-is-the-main-difference-between-a-stubs-a-mock

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
