Thursday, 26 November 2020

Mocks Vs Stub

 

Test Doubles --> Mocks (mock, spy)     Stub (stub, dummy, fake)


Mock

  • Waits to be called by the class under Test.

  • Mock object are used for behaviour verification.

  • Mock can fail the test.

  • It can provide data and logic needed by the class.

source: internet


Stub

  • Gives out data that goes under class/object under test.

  • Stub object are used for state verification.

  • Stub cannot fail the test, it returns stub value.

  • Data is directly injected into the class.



Thank you!



Satender Kumar Mall
Twitter: @satenderiiit

No comments:

Post a Comment