Skip to content
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

make the output from --list-tests usable as a --filter parameter when there is a data provider #4129

Open
joachim-n opened this issue Mar 2, 2020 · 3 comments
Labels
type/enhancement A new idea that should be implemented

Comments

@joachim-n
Copy link

If I use --list-tests, I get a list of all the data sets from the data provider:

$ vendor/bin/phpunit Test/Unit/ComponentPHPFile8Test.php --list-tests
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

Available test(s):
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"nothing"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"PHPStorm type var first"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"PHPStorm type class first"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"parameter typehint"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"static call"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"class"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"new"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"repeated"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"current"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"docblock param"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"comment"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"quoted class name"
 - DrupalCodeBuilder\Test\Unit\ComponentPHPFile8Test::testQualifiedClassNameExtraction"double quoted class name"

However, these are not in a format that (AFAIK) can be used with the --filter option. That needs an @ before the quote marks (and the quote marks are only needed if there are spaces in the data set name):

$ vendor/bin/phpunit Test/Unit/ComponentPHPFile8Test.php --filter=testQualifiedClassNameExtraction@"parameter typehint"

Proposed improvement: print the '@' between the method name and the dataset name in the output, so it's easier to copy-paste it to run a test.

@joachim-n joachim-n added the type/enhancement A new idea that should be implemented label Mar 2, 2020
@perk11
Copy link

perk11 commented Dec 5, 2020

I'm looking for a way to run tests in parallel, invoking --filter to run phpunit with just a single test, and currently there is no easy way to get a list of tests in a test suite that could be passed back to --filter.

@mfn
Copy link

mfn commented Dec 5, 2020

@perk11 you may be interested in #4449

  • uses existing --list-tests-xml
  • (needs external software to split the XML, PoC provided)
  • adds the ability to feed such a XML list back and only execute these tests

@perk11
Copy link

perk11 commented Dec 5, 2020

Thanks, that looks like it can work. I found that paratest can already do what I need, but for something more custom or even to make building something like paratest possible that doesn't depend on PHPUnit internals, #4449 would be a useful change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A new idea that should be implemented
Projects
None yet
Development

No branches or pull requests

3 participants