I'm writing a lot of unit tests and I'm afraid one day I'll come back to read the test codes and not be able to understand what's being tested.
The question is: How do i document PHPUnit tests using PHPDoc?
Use the @covers
annotation (it's specific to PHPUnit, not a documentation tag used by phpDocumentor) to highlight what the test case is supposed to exercise. By having it in the docblock, you tell the code reader what code is targeted by the test. If you have phpDocumentor also generating docs for your test cases, then it should treat the annotation as a "custom tag", and show it as generic information. Note, though, that the point of @covers
is to limit the code coverage measurements done by PHPUnit. Its use as doc info is incidental, but useful.
If you want some kind of document linking between the test case and the tested code, also put the @uses
tag in the test case's docblock. That should result in @used-by
tag automatically appearing in the documentation for the tested method/function.