This might be a stupid question, but I can’t seem to make it to work.
I’m using PHPUnit to test. Currently I have two classes in a file called Tests.php:
class XTest extends PHPUnit_Framework_TestCase {...}
class YTest extends PHPUnit_Framework_TestCase {...}
However, I’m unable to run both classes. I’m running the following command on Windows:
php "C:\Program Files (x86)\PHP\phpunit" Tests
And it tries to run a test class called “Tests”. Instead, I’d like it to run “XTest” and “YTest” and all that are on the file. How could I run multiple test classes easily?
The PHPUnit Docs explain the arguments the command line test runner expects.
In your case, you’re providing
Tests, which means PHPUnit looks for a classTestsin a fileTests.php.With this knowledge, it’s easy to see that the best way to organise your tests will be to write one test class per file, with the filenames equal to
TestClassName.php.However, if for some reason you don’t want to do that, you can provide an extra argument to tell the test runner which file the test class is declared in: