Contract and collaboration tests

Collaboration and contract tests

A collaboration test is an example of interactions between the subject of the test and its collaborators. For convenience, speed, reliability, or isolation, collaborators are often replaced with test doubles. A contract test confirms assumptions made in test doubles. Writing tests for pure functions or methods with no side effects is straightforward. Given the input, when the behaviour is invoked, let me verify the expected outcome matches the actual outcome. ...

August 16, 2022 · 5 min · 929 words · Jakub Zalas
On granularity of tests focused on behaviour

On granularity of tests focused on behaviour

Behaviour A function is one of the smallest units of behaviour. Given an input, it returns the output. Function This means that given the context (input), the function’s behaviour can be verified by calling the function and looking at the outcome (output). Notice that the most straightforward outcome to verify is the function’s return value, but it’s not the only outcome we can look for. Functions can have side effects, modify state, interact with collaborators, etc. ...

May 17, 2022 · 4 min · 703 words · Jakub Zalas