I have tests of various types (unit, acceptance, etc) which I have assigned multiple labels for granularity
/**
* @test
* @group unit
* @group controllers
*/
/**
* @test
* @group unit
*/
/**
* @test
* @group controllers
*/
Is it possible to run phpunit tests that only match two or more groups? Something like
--group unit|controllers
In this case the only test that should run would be the first test as it has both the unit
and controllers
group while the other tests would not run.
Using the notation
--group unit,controllers
Runs all tests from unit
and then all (or remaining - I can't quite remember) tests from controllers
- In large projects this can cause long run times.
As seen in testng.xml, the groups are included under the <group> tag. As we want to run the tests included under both the groups (group1 and group2), we include the required group names under the <run> tag.
The matching method in the class is test_BingSearch (). TestNG_ToDoGroup class: To run test methods whose name includes “.*ToDoApp.*” and exclude test method (s) whose name contains “.*Test1.*”, we use method groups in the following manner: The matching method in the class is test_Selenium4_ToDoApp_Test2 ().
To run tests that match a tag or several tags, you can do one of the following: In the Execution Plan editor of your project, create a test item and assign a tag or a tag expression to it. In a keyword test, use the Run Test operation to run tests that match a tag or a tag expression.
Therefore, methods typically used for within-participant comparisons (e.g. paired/dependent samples t-tests, repeated measures ANOVA, etc.) would normally be appropriate.
--group unit,controllers
should work--exclude
also exists to run all tests except those in the group(s) specified@group unit|controllers
is not an allowed syntaxYou need to rethink usage of @group annotations, start with splitting to test suites. You can try to follow phpunit rules about files structure or define test suites using xml. For ex:
<phpunit bootstrap="src/autoload.php">
<testsuites>
<testsuite name="unit">
<directory>webroot/*/Tests/Unit</directory>
</testsuite>
<testsuite name="integration">
<directory>webroot/*/Tests/Integration</directory>
</testsuite>
<testsuite name="controllers">
<directory>webroot/*/Tests/Integration/Controller</directory>
</testsuite>
</testsuites>
</phpunit>
@groups usually used to combine by business entity, for ex. to run all tests related to search functionality of your application.
more information here https://phpunit.de/manual/current/en/organizing-tests.html
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