From 6f7e2df23b784687e2b643e733c878e454800e54 Mon Sep 17 00:00:00 2001 From: Jorge Cabrera Date: Tue, 24 Sep 2019 23:53:54 -0700 Subject: [PATCH] Formatting update --- text/41_advanced_unit_testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/41_advanced_unit_testing.md b/text/41_advanced_unit_testing.md index 69c57a0..adc5ab6 100644 --- a/text/41_advanced_unit_testing.md +++ b/text/41_advanced_unit_testing.md @@ -346,7 +346,7 @@ public class DuckPond extends Pond { } ``` -Let's set aside any issues one might have about how this code is written, and how it might be refactored to make it more testable. In this case, calling haveUltraFun() requires querying the database, which is called from a method from DuckPond's superclass. However, this also modifies the `_funLevel` variable, based on the value it received from the `retrieveUltraLevelFromDatabase()` call. The value of the variable `_funLevel` is going to depend both on that call to the database as well as how many times `haveFun()` and `haveUltraFun()` have been called. While it would be possible to just make a test double that returns specific values, adding in this behavior for a test which called multiple methods on a DuckPond object might add up to lots of extra work. Even worse, this work might have to be replicated in multiple tests. +Let's set aside any issues one might have about how this code is written, and how it might be refactored to make it more testable. In this case, calling `haveUltraFun()` requires querying the database, which is called from a method from DuckPond's superclass. However, this also modifies the `_funLevel` variable, based on the value it received from the `retrieveUltraLevelFromDatabase()` call. The value of the variable `_funLevel` is going to depend both on that call to the database as well as how many times `haveFun()` and `haveUltraFun()` have been called. While it would be possible to just make a test double that returns specific values, adding in this behavior for a test which called multiple methods on a DuckPond object might add up to lots of extra work. Even worse, this work might have to be replicated in multiple tests. Using DuckPond as-is also means that every call to `haveUltraFun()` will result in a dramatic slowdown in tests. Remember that calls to the disk or network, since they make take an order of magnitude or longer in time than the test would take otherwise, are discouraged in unit testing.