Test doubles: Difference between revisions
Created page with " A '''wp:Test double''' is any object that stands in for a real dependency in automated testing. Usually in PHPUnit, we make test doubles for other classes, but you can also double PHP native functions or closures. There are 5 types of Test doubles <ul> <li> Dummy - "A dummy argument" - used as a placeholder when an argument needs to be passed in. <li> Stub - Provides fake or 'canned' data to the System Under Test (<abbr title="System Under Test is the class tha..." |
No edit summary |
||
| Line 3: | Line 3: | ||
There are 5 types of Test doubles | There are 5 types of Test doubles | ||
; Dummy | |||
: "A dummy argument" - used as a placeholder when an argument needs to be passed in. | |||
; Stub | |||
: Provides fake or 'canned' data to the System Under Test (<abbr title="System Under Test is the class that the Automated Test is targeting">SUT</abbr>). | |||
; Spy | |||
: Records information about how it is used, and can provide that information back to the test. | |||
; Mock | |||
: Defines an expectation on how it will be used, and with what parameters. Will cause a test to fail automatically if the expectation isn’t met. | |||
; Fake | |||
: "Looks real, but it's not." An actual (simplified) implementation of the contract, unsuitable for production. | |||