Can phpunit use multiple data provider

前端 未结 5 739
渐次进展
渐次进展 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:14

    Just an update to the question, a pull request was accepted and now the code:

    /** 
     * @dataProvider provideInvalidId
     * @dataProvider provideFailedId
     */
    public function testGetByIdUnsuccess($id)
    {   
        $this->assertNull($this->model->getById($id));
    }
    

    Will work on PHPUnit 5.7, you'll be able to add as many providers as you want.

提交回复
热议问题