Can phpunit use multiple data provider

前端 未结 5 745
渐次进展
渐次进展 2021-02-06 22:50

One question in short: can phpunit use multiple data provider when running test?

For example, I have a method called getById, and I need to run both successful and unsuc

5条回答
  •  囚心锁ツ
    2021-02-06 23:30

    well,you could consider it from another side ;) you know exactly what is your expected,for example getById(1) expected result is $result_expected,not $result_null so,you could make a dataprovider like this

    $dataProvider = array(1, 'unexpected');
    

    then,your test method like this:

    public function testGetById($id) {
        $this->assertEquals($result_expected, $obj::getById($id));
    }
    

    so,test result is:

    .F
    

提交回复
热议问题