On Sat, Dec 29, 2012 at 1:47 PM, Bryan Tong Minh
<bryan.tongminh(a)gmail.com>wrote;wrote:
This is an annoyance to me as well. So, I went triaging, and finally found
the issues that failed the unit tests for me. I have committed fixes for
them to gerrit:
https://gerrit.wikimedia.org/r/#/c/41362/
https://gerrit.wikimedia.org/r/#/c/41360/
This sort of thing has come up before. Michael Feathers, author of Working
Effectively with Legacy Code (
http://www.artima.com/weblogs/viewpost.jsp?thread=126923), etc. published a
guideline for unit tests in 2005:
http://www.artima.com/weblogs/viewpost.jsp?thread=126923:
A test is not a unit test if:
It talks to the database
It communicates across the network
It touches the file system
It can't run at the same time as any of your other unit tests
You have to do special things to your environment (such as editing config
files) to run it.
I am not a great writer of unit tests, especially in PHP, but it is my
impression that we have quite a few existing tests that don't follow this
guide. In Bryan's example above, having a unit test depend on the
existence of gzip would be a code smell.
I don't think it's an immediate priority, but over time it would probably
make sense to refactor the tests that don't follow this guide to use mocks
and stubs and other accepted practices to avoid requiring a particular
environment to run unit tests.
-Chris