Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit live log on failure/error

I've been running a few thousand phpunit tests recently. I use --process-isolation option so it takes some 40 minutes for tests to complete.

Sometimes after an aggressive refactoring a lot of tests start failing (thanks God I have the tests !). And if a test fails in the middle of a test suite then I have to wait 20 more minutes to see what test it is and it's message.

I would use --stop-on-failure if didn't interrupt the whole process. Basically I'm looking for --log-on-failure option.

What I'm looking for exactly is some way to see the fail/error message of the test right after it failed and not after all other tests are finished. But the whole process of other tests execution should not be interrupted. Logging to a file will suffice as well.

I'll appreciate your suggestions.

EDIT: I'm glad to see your suggestions how I could improve my testing in general and I will try to follow them, however I would like to find a solution to my exact problem.

like image 797
Igor Malyk Avatar asked Oct 22 '22 18:10

Igor Malyk


1 Answers

Even if you neglegt it, you are looking for --stop-on-failure.

Because when you see where the error is, you can write the fix. Then you need to run the tests again.

If you would only log on failure, you could not yet run the tests again because let's say after 10 seconds the first failure is visible and fixed within another minute. However you still need to wait ca. 38 minutes until you can run the tests.

Also the other problem you have is that your tests are taking too long. You need to get them faster. That you're using --process-isolation is eventually a sign that you have integration tests. Separate those from your unit-tests, they often take longer.

Then you can run the integration tests in isolation and continuously (in a loop, always) and you run the unit-tests when you save your files.

like image 57
hakre Avatar answered Oct 26 '22 22:10

hakre