January 2019
Intermediate to advanced
272 pages
7h 40m
English
This chapter covers
As a test suite grows in size, you start to see repeated code. One way to avoid this is to use factory functions to organize tests.
Factory functions are functions that return new objects or instances (you might know them as builders). You can add factory functions to tests that require repetitive setup to remove code duplication.
Using factory functions is a pattern that helps keep test code easy to read and understand. In this chapter, you’ll learn what factory functions are, how they can reduce repetition in tests, and how they improve your test code structure.
After you’ve learned what factory ...
Read now
Unlock full access