I am working on re-configuring our php unit test setup and ran into a need to run tests that belong to a specific group by only if they also belong to another group. For example, I may have something like this:
/**
* ...
* @group Alpha
* @group area1
*/
class TestAlpha extends PHPUnit_Framework_TestCase
{
public function testTest1() {
...
}
public function testTest1() {
...
}
}
/**
* ...
* @group numeric
* @group area1
*/
class TestNumeric extends PHPUnit_Framework_TestCase
{
public function testTestA() {
...
}
public function testTestB() {
...
}
}
If I only want to run tests from area1
group, I would use
phpunit --group area1
However I also need to be able to run tests from area1
group but only if they also belong to numeric
group.
If I run phpunit --group area1,numeric
, the tests will be included if they are in one or the other group. How can I run phpunit to only include tests if they are in one and the other group? Sort of like --filter
parameter but on a group level.
Just to note, I'm dealing with an existing suite of several hundred test classes and massively restructuring the tests (e.g. in separate suites) isn't something I can afford at the moment.