Skip to content

What is stub

Devrath edited this page Jun 26, 2021 · 2 revisions

Where you need to use stubs

  • There are scenarios where I want to check what my function returns and based on that I want to check how my code works. This is the ideal scenario for the usage of stubs.
  • Generating predefined output.
  • We check if the piece of code returns success, failure, exception based on the block of the code.
  • If there is a piece of code inside the function that causes the exception and we need to check this we can use stubs.

Summarizing

We use stubs to check the behaviour of the code under test

Clone this wiki locally