Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Dependency Reduction (Mocks and Stubs)

Unknown edited this page Jul 1, 2020 · 1 revision

Mocks and Stubs

example signature

int add5(int a){...}

int returnX(int a){...}

Mocks

must have the same signature like add5!!

Mocks do have access to the same variables like the origin function usage:

whenMock(add5,returnX);

if add5() gets called the call gets replaced with returnX()

but returnX must have the same signature

Stubs

Stubs to no requiriere the same signature but the same return value

Stubs allow to return every expression as long the expression do have the same return value as the origin function.

whenStub(add5,"100");

whenStub(add5,"50 +50");

whenStub(add5,"100");

whenStub(add5,"add(5,5)");

Delete all Stubs and Mocks

by calling "deleteAllMocks()"

Clone this wiki locally