Take the 2-minute tour ×

PHPUnit manual say:

If you point the PHPUnit command-line test runner to a directory it will look for *Test.php files.

see: http://www.phpunit.de/manual/3.6/en/organizing-tests.html#organizing-tests.filesystem

This is wrong!

When i call:

phpunit --config myconfig.xml --bootstrap mybootstrap.php tests

It takes all php files.

  1. First idea was to use blacklist or whitelist in the config xml, but then i realised, that these lists are filters for subject under tests and filters test classes.
  2. Second thought was to use testsuites within the config xml. But at the moment the test suites can be defined only, but not executed via command line (not jet implemented in PHPUnit, ticket is open for more than 1 year).
  3. Next thought was to use a test suite loader, but i can not find a documentation on how to use them and if a tsl is what i think it is.

When i run:

phpunit --config myconfig.xml --bootstrap mybootstrap.php --loader My_Testsuite_Loader tests

PHPUnit takes all php file in "tests/" and executes them. The file "My/Testsuite/Loader.php" will be included. PHPUnit checks if the class My_Testsuite_Loader exists. All fine so far.

I used the "PHPUnit/Runner/StandardTestSuiteLoader.php" as template for "My/Testsuite/Loader.php". It contains the methods "load()" and "reload()". Both methods are never called by the PHPUnit Framework. Why not? I thought to have a own testsuiteloder will give me the oportunity to implement a test suite exclude schema.

Sample file system of my project:


As you can see i use one file for all tests about a sut (method under test). All these *Test.php files inherits from TestTemplate (TestCase). In TestTemplate.php is a setup which initializes the object (Object.php) and stores it in a private member var.

How to use the test suite loader / for what is it meant to be? (How to exclude test classes that do not fit to the pattern: "*Test.php"?)

share|improve this question
Firstly, there is no such flag as --config, it is either -c or --configuration. Secondly, You don't have to provide neither a bootstrap file nor the test suite loader, if You're already providing a configuration file, all can be set there. Thirdly, You don't even have to provide a configuration file, as long as it's called phpunit.xml or phpunit.xml.dist and You call the phpunit script from the right directory. Fourthly, the documentation is correct about what You think is wrong. And finally, i think the problem might be in your configuration file. Could You show what's in there? –  zafarkhaja May 8 '12 at 9:23
@zafarkhaja: you are right about --config. You can override xml settings by using command line switches, and this can make sense if you try to integrate phpunit into an IDE (different run configurations, but a shared xml). –  DanielaWaranie Jun 29 '13 at 0:09
@DanielaWaranie, yes, indeed. In those cases it makes sense. Thank you. –  zafarkhaja Jun 29 '13 at 16:26
add comment

1 Answer

You need to take out the 'tests' argument like so

phpunit --config myconfig.xml --bootstrap mybootstrap.php

Then in your myconfig.xml

   <testsuite name="AllTests">

    <directory suffix=".xml">.</directory>
share|improve this answer
add comment

Your Answer


