What Makes a Good Test?

The following are some generic rules that are valid for any unit test and not just PHPUnit:

Independent: Each test needs to run independently from other tests
and environments.

Fast: To have useful tests and be able to run them as often as possible
(for example, as pre- or post-commit hooks), tests need to be fast.

Repeatable: You should be able to run a test as many times as you want with the same result.

Up to date: Tests are written once, but code can be changed or extended. If you are not going to keep tests up to date, the initial investment in tests will be just a waste of time and money. The rule is, whoever breaks the test, fixes the test.

Short: Tests should be just a few lines—easy to read and understand.

Resilient: Once written, tests shouldn’t change till the behavior of tested
class/method changes.

PHPUnit Essentials  – by Zdenek Machek