-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support filtering using --filter
, --exclude-filter
, --group
, and --exclude-group
when listing tests using --list-tests
and --list-tests-xml
as well as listing groups with --list-groups
#5720
Comments
After the preparation work that was already done in https://github.com/sebastianbergmann/phpunit/tree/issue-5720/support-filtering-when-listing-tests, this should be as simple as this: diff --git a/src/TextUI/Command/Commands/ListTestsAsTextCommand.php b/src/TextUI/Command/Commands/ListTestsAsTextCommand.php
index de8d3bde9..3cb4dc252 100644
--- a/src/TextUI/Command/Commands/ListTestsAsTextCommand.php
+++ b/src/TextUI/Command/Commands/ListTestsAsTextCommand.php
@@ -15,6 +15,7 @@
use PHPUnit\Framework\TestSuite;
use PHPUnit\Runner\PhptTestCase;
use PHPUnit\TextUI\Configuration\Configuration;
+use PHPUnit\TextUI\TestSuiteFilterProcessor;
use RecursiveIteratorIterator;
/**
@@ -35,6 +36,8 @@ public function execute(): Result
{
$buffer = 'Available test(s):' . PHP_EOL;
+ (new TestSuiteFilterProcessor)->process($this->configuration, $this->suite);
+
foreach (new RecursiveIteratorIterator($this->suite) as $test) {
if ($test instanceof TestCase) {
$name = sprintf( Unfortunately, it is not:
The When we change the command like so ... diff --git a/src/TextUI/Command/Commands/ListTestsAsTextCommand.php b/src/TextUI/Command/Commands/ListTestsAsTextCommand.php
index de8d3bde9..64bb80ad4 100644
--- a/src/TextUI/Command/Commands/ListTestsAsTextCommand.php
+++ b/src/TextUI/Command/Commands/ListTestsAsTextCommand.php
@@ -15,6 +15,7 @@
use PHPUnit\Framework\TestSuite;
use PHPUnit\Runner\PhptTestCase;
use PHPUnit\TextUI\Configuration\Configuration;
+use PHPUnit\TextUI\TestSuiteFilterProcessor;
use RecursiveIteratorIterator;
/**
@@ -35,7 +36,9 @@ public function execute(): Result
{
$buffer = 'Available test(s):' . PHP_EOL;
- foreach (new RecursiveIteratorIterator($this->suite) as $test) {
+ (new TestSuiteFilterProcessor)->process($this->configuration, $this->suite);
+
+ foreach ($this->suite as $test) {
if ($test instanceof TestCase) {
$name = sprintf(
'%s::%s', ... then we do not run into the error shown above, but it also does not work:
I am leaving the above information here for "future me" or anybody else who wants to debug this mystery. As for myself, I think we would be better served to refactor how filtering is performed. This is what I will look into next ... |
The On the |
thank you! |
--filter
, --exclude-filter
, --group
, and --exclude-group
when listing tests using --list-tests
and --list-tests-xml
--filter
, --exclude-filter
, --group
, and --exclude-group
when listing tests using --list-tests
and --list-tests-xml
as well as listing groups with --list-groups
No description provided.
The text was updated successfully, but these errors were encountered: