Runing a single test case in PHPUnit
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
Sometimes when you're trying to nail down a failing test you need a quick way to run just the thing thats broken, instead of your whole suite or a whole test case. Fortunately it's pretty simple with the --filter
flag provided by PHPUnit.
If for whatever reason I'm having trouble with the terms page I can easily just run that failing test by calling --filter
and providing the name of the test.
Better yet, it can match the start of test names. So, despite it being bad example above, if I wanted to run all the tests that start with it_displays_
, I could go --filter it_displays_
and it'll run all the matching tests.