Cannot run single test with data provider in PHPUnit

后端 未结 5 415
失恋的感觉
失恋的感觉 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 13:02

    The regex in the answer no longer seems to work (at least not in 4.0.12).

    It looks like --filter doesn't like the space, and gives the following error:

    Fatal error: "preg_match(): Compilation failed: missing ) at offset

    This is fixed by replacing the space with \s The quotes also need to get removed (or else the \ needs to be \)

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

提交回复
热议问题