June 2025
Intermediate to advanced
837 pages
24h 50m
English
The tests we’ve written so far all look like they came out of a textbook. There is a function that receives a defined input and generates a specific output from it. Unfortunately, real life isn’t always that nice. Sometimes, the need arises to enter dependencies between different files or to include modules. However, in your unit test, you only want to test your own function and not a third-party package. The solution to this problem is called mocking. In this context, you replace the external dependency with something that is completely under your control within your test environment.
As an example of this problem, let’s assume we need to implement a countLines function. This function accepts a file ...
Read now
Unlock full access