Introduction to Stubbing
Get familiar with the concept of stubbing in automated testing.
We'll cover the following
In unit testing, stubbing refers to a technique used to isolate the code being tested by replacing certain parts with simplified implementations, often called stubs. Stubs are essentially placeholder functions or objects that mimic the behavior of the real components, but they’re designed to return predefined values or perform predefined actions. The purpose of stubbing is to control the behavior of external dependencies or collaborators during unit testing, ensuring that the test focuses only on the specific unit of code being tested.
Stubbing and mocking are related concepts used in automated testing, and they both involve creating fake or simulated objects to isolate and control dependencies. However, they serve slightly different purposes, as shown in the following table.
Get hands-on with 1400+ tech skills courses.