Fakes

Fakes are the last and most powerful type of test double. A fake is a class that attempts to behave as if it weren't a test double. While a fake will not connect with a database, it will attempt to behave just like it is connecting to a database. A fake will not use the system clock, but it will attempt to have an internal clock that behaves as close to the system clock as possible.

Fakes either add extra testing functionality or prevent external interference from third-party libraries and systems. Most applications are connected to some data source. A fake repository can be created that uses its own in-memory data source but otherwise behaves just like a normal data connection.

Fakes are created by generating a whole new class or method and then writing enough functionality to be indistinguishable from the production class or method. The only important distinction for a fake versus a production class or method is that the fake does not make external connections and likely has the ability for the tester to control the underlying data set.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.172.146