Test doubles: Difference between revisions
| Line 18: | Line 18: | ||
== Dummy == | == Dummy == | ||
"A dummy argument" - used as a placeholder when an argument needs to be passed in. | |||
In the example code below, we have a '''User''' class that we want to write a test for. The User object needs a Logger object passed as a parameter to its constructor. So, in the '''UserTest''' class, we create a dummy to pass to the system under test. The test double "Logger" doesn't have to do anything at all - it just exists to be passed as an argument during the test. | In the example code below, we have a '''User''' class that we want to write a test for. The User object needs a Logger object passed as a parameter to its constructor. So, in the '''UserTest''' class, we create a dummy to pass to the system under test. The test double "Logger" doesn't have to do anything at all - it just exists to be passed as an argument during the test. | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||