问题
I am able to run a single test from a suite using --filter
option.
I am wondering if there is a way to dynamically run multiple tests under the suite?
Thanks
回答1:
A simple regex to filter for multiple tests could look like --filter '/test1|test2|test4/'
. This will match any tests which contain 'test1' 'test2' or 'test4' so for example test43 would be included, but test3 would not get run. The check is case-sensitive.
回答2:
The --filter option runs tests whose name matches the given regular expression pattern, so you should be able to select multiple tests by providing a suitable regular expression as argument.
See the documentation for the PHPUnit command line test runner
回答3:
I recommend usage of "spatie/phpunit-watcher" (https://github.com/spatie/phpunit-watcher) that will allow you to perform this type of filtering
回答4:
So I ended up creating my own configuration file with all the tests that I need and then pass it via --configuration
to PHPUnit.
回答5:
Work for me :
phpunit -c phpunit.dist.xml src --filter '/NameSpace\\UserBundle/|Namespace\\OtherBundle'
Do not work for me :
phpunit -c phpunit.dist.xml src --filter "/NameSpace\\UserBundle/|Namespace\\OtherBundle"
Whit double quote the result for me is "No tests executed!"
If you don't use \ in filter (for namespace) then double quote work perfectly but with namespace\bundle on my setup I need to use single quote.
来源:https://stackoverflow.com/questions/50800071/how-to-filter-for-multiple-tests-in-phpunit