Cannot run single test with data provider in PHPUnit

后端 未结 5 417
失恋的感觉
失恋的感觉 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条回答
  •  梦毁少年i
    2021-02-05 12:39

    By using a data provider with named datasets it's simpler now:

    public function provideData()
    {
        yield "dataset name 1" => [
            $expected = 0,
            $val1 = 1,
            $val2 = 2
        ];
    
        yield "dataset name 2" => [...];
    }
    

    $ phpunit --filter "dataset name 2"

提交回复
热议问题