douyigua5381 2018-10-01 00:46
浏览 123

PHPUnit - 来自dataProvider的“流式传输”数据(连续模式)

I like to use PHPUnit as a framework for functional (fuzzy) testing. Is it possible to force PHPUnit to run tests one-by-one, after each dataProvider request?

For now it wants to fetch all data from dataProvider before running tests, and if my generator-based dataProvider has while(true){} loop (which is legal for generators), PHPUnit hangs.

Next dataProvider works as expected (limited tests number):

  public function randomArrayProvider()
    {

        for ($i=0; $i<300 ;$i++)
        {
          $aa = $this->buildArraySample();
          yield json_encode($aa) => [$aa];
        }
    }

And this one hangs:

   public function randomArrayProvider()
    {

        while(true)
        {
          $aa = $this->buildArraySample();
          yield json_encode($aa) => [$aa];
        }
    }

Is there a way to run above unlimited generator-based test sequence with PHPUnit?

Note: I have no issues with running above test data "streaming" scenario from php-cli. Just want to integrate it into PHPUnit testing suite, together with unit tests, etc.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥188 寻找能做王者评分提取的
    • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
    • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
    • ¥15 写论文,需要数据支撑
    • ¥15 identifier of an instance of 类 was altered from xx to xx错误
    • ¥100 反编译微信小游戏求指导
    • ¥15 docker模式webrtc-streamer 无法播放公网rtsp
    • ¥15 学不会递归,理解不了汉诺塔参数变化
    • ¥15 基于图神经网络的COVID-19药物筛选研究
    • ¥30 软件自定义无线电该怎样使用