2017-08-02 14:58

如何在Laravel 5.4中输出有关执行测试的信息


I have set up multiple tests for my laravel api, but when I run the unit-test, all I get is:

~api$ ./vendor/bin/phpunit tests/v1/
Time: 171 ms, Memory: 8.00MB
OK (3 test, 4 assertion)

I would like to get an output similar to command's info method (maybe even progress bar if the tests execution start to take long period of time):

$this->output->info('Starting data fetch ...');

so that I can see, what tests are performed. The desired result would be:

~api$ ./vendor/bin/phpunit tests/v1/
Running PassportTest
Running DescribeTest
Running UserListTest

Time: 171 ms, Memory: 8.00MB
OK (3 test, 4 assertion)

What is the correct way to do this for each test I've created?

Edit: So far I managed something similair to it with Dumper:

(new Dumper())->dump('PassportTest');

This gives me a quoted text:

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dougengqiu8031 dougengqiu8031 4年前

    You can use a --debug flag:

    ~api$ ./vendor/bin/phpunit tests/v1/ --debug

    ------ output ------

    Starting test 'Class::yourTestMethod'.
    . //(Result like: ., E, F, etc)
    Starting test 'Class::otherTestMethod'.
    F //(Result like: ., E, F, etc)

    I usually add two more flags to help me in the analysis:

    --log-json: to output the log files to json

    --tap: to generate a test summary file (execution times and results)

    See the docs:

    点赞 评论 复制链接分享