On Tue, Mar 5, 2013 at 1:25 PM, Ori Livneh <[email protected]> wrote:
> A short while ago I wrote a set of three PHP unit tests for Math that use 
> test doubles to stub out external dependencies (in this case, the 
> database-backed cache and the texvc executable). My intent was to demonstrate 
> the technique to another developer, so I commented the code extensively. It 
> occurred to me that other people might be interested, too, so I'm sharing it 
> here.
>
> The advantage of such tests is that they typically faster and far less 
> brittle than tests that rely on external resources. They also make test 
> results less noisy: if the test fails, you know that it's because your code 
> was wrong, and not because the database happened to suffer an outage. 
> Finally, they are more portable, because they don't require that you 
> configure external dependencies to make them work.
>
> If you are interested, check out the example, and the relevant chapter in the 
> PHPUnit docs.
>
> https://gerrit.wikimedia.org/r/#/c/49612/1/tests/MathTexvcTest.php
>
> http://www.phpunit.de/manual/current/en/test-doubles.html

This is awesome, thanks for doing this Ori!  Glad to see progress in
the direction of our unit tests truly being unit tests.[1]

Rob
[1] Optional reading on unit-tests vs integration tests for those that
don't know what I'm talking about:
http://www.sandywalsh.com/2011/06/effective-units-tests-and-integration.html

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to