Answer to@Schleis is completely correct and very useful. The only catch (which I admittedly did not include in my question) is that I would like to scatter Unit and Integration tests in our test files - I want to avoid two test files - one file for unit tests for SomeClass and separate file for functional tests, also for SomeClass.
The PHPUnit command-line option I found that allows these groups :
--group
Only runs tests from the specified group(s). A test can be tagged as belonging to a group using the @group annotation.
To use this approach, you simply add an annotation @groupto the multi-line comment before your tests as such:
class SomeClassTest extends PHPUnit_Framework_TestCase {
public function testSomeUnitFunctionality() {
$this->assertEquals(xyz(' .a1#2 3f4!', true), ' 12 34');
}
public function testSomeIntegrationFunctionality() {
$this->assertEquals(xyz(' .a1#2 3f4!', true), ' 12 34');
}
}
This allows me to do the following:
phpunit --group Unit (Unit tests only)phpunit --group Integration (Integration tests only)phpunit (All tests)