How to send phpunit errors to Laravel log channels? i.e. slack?

396 Views Asked by At

we are implementing functional testing in our Laravel app environment and we want the results of phpunit dusk tests to be logged in a slack channel via webhook. Anyone?

We achieved to log results in single files as described in documentation (using phpunit --log-TypeOfLog) but we want to receive notifications when we run that tests in automated mode in other channels.

We can manually send notifications to slack (or other channels) if we put Log::error('Something happened!'); but we want this to be automatically done when tests finish.

1

There are 1 best solutions below

0
N69S On

You can run the command for phpunit like this

(vendor/bin/)phpunit |grep Failures > failed_tests.txt

Then after that cron run another that checks if the file failed_tests.txt is not empty. If so send it with mail and empty/delete/archive it