Peon
Peon

Reputation: 8020

How to output info about performed test in 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:

"PassportTest"

Upvotes: 0

Views: 1365

Answers (1)

Jean Marcos
Jean Marcos

Reputation: 1177

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: https://phpunit.de/manual/current/en/textui.html

Upvotes: 1

Related Questions