I have a PHPUnit Test class that I'd like to be ignored from a test run. I know I can do it by renaming it so that it doesn't contain the word Test in its filename, but I'd rather not do that since it muddies up the source control waters more than I'd like.
Does anyone have a suggestion?
There are a couple of options for the phpunit
command that can help define which tests should and should not be run :
$ phpunit --help
PHPUnit 3.4.0beta5 by Sebastian Bergmann.
Usage: phpunit [switches] UnitTest [UnitTest.php]
phpunit [switches] <directory>
...
--filter <pattern> Filter which tests to run.
--group ... Only runs tests from the specified group(s).
--exclude-group ... Exclude tests from the specified group(s).
--list-groups List available test groups.
...
Those will probably not allow to specify exactly what you wanted... But they might help.
For more details, see The Command-Line Test Runner
Especially, I kind of like the group feature : just use a @group
tag in the phpdoc of your tests, to re-group them (for instance, one group per "chunk of functionnality") ; and, after, you can use the --group
or --exclude-group
options on the command line to specify which tests should or shouldn't be run.
In your case, if you cannot modify the tests, maybe the --filter option can help, depending on how your tests are nammed (ie, if there is a way to identify those you want to run) :
--filter
Only runs tests whose name matches the given pattern. The pattern can be either the name of a single test or a regular expression that matches multiple test names.
Another solution, if you are not always changing the "groups" of tests to run, might be to use a test-suite that only includes the tests you want to run.
For instance, take a look at Composing a Test Suite Using XML Configuration.
simply rename your method :
testFunctionality () { //blah }
to
ignore_testFunctionality () { //blah }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With