September 2023
Intermediate to advanced
470 pages
11h 12m
English
As we saw, the smallest and most common test is the unit test. It’s always a good idea to write a test before trying to solve a problem in code. But what does writing tests mean in practice? And how does functional programming differ from the traditional style?
One of the most-used templates for writing unit tests is called Given-When-Then (another name for it is Arrange-Act-Assert).[13] It works by splitting each test into three steps:
We can apply it to functional programming as well: “Given 2 and 3, when I sum them, then I get 5 as result.”
Even if it seems similar to the functional approach, in practice, it leans toward setting the ...
Read now
Unlock full access