Cannot run single test with data provider in PHPUnit

后端 未结 5 416
失恋的感觉
失恋的感觉 2021-02-05 12:13

I\'ve got a problem when using command line to run tests: if I run phpunit like this:

phpunit -–no-configuration -–filter testAdd DataTest DataProviderTest.php         


        
5条回答
  •  一整个雨季
    2021-02-05 12:54

    The regex to handle tests with or without data sets is

    phpunit --filter "/::( with data set .*)?$/"  
    

    For example

    phpunit --filter "/::testAdd( with data set .*)?$/" DataTest DataProviderTest.php
    

    Since a test method won't have a space in the name unless it has a data set, you could really shrink this to

    phpunit --filter "/::testAdd( .*)?$/" DataTest DataProviderTest.php
    

提交回复
热议问题