Closed florentpoujol closed 6 years ago
@florentpoujol First of all, my apologies from breaking things for you. I certainly did work around this area (to add pretty printing for output)
Could you please provide some additional information?
I have the same issue with Laravel 5.7.9, PhpUnit 7.4.0 and your plugin at version 0.23.2.
It occurs when an \Exception
is thrown (with a custom message), except if I use expectException
method in my test.
Without your plugin, the stacktrace is printed correctly.
Yes, here more info:
So after all the tests have run, PHPUnit display the status of the one that fails, as well as any exception that were thrown either from the test classes themselves, or from within the application's code.
The problem I have lies in displaying this last kind of exception: instead of displaying all the exceptions that were throw -and independently of how many of them were thrown- I only see the error I gave in the first post, exactly twice.
The message indicates that someone tried to resolve the Illuminate\Contracts\Debug\ExceptionHandler
interface through Laravel's DI container and that what it resolved isn't an instance and isn't intantiable...
While the tests are running, and outside (accessing a controller via the browser), there is no issue resolving the application's exception handler.
There is no issue displaying successes or test failures or Exception throw from the test classes (note: I'm not extra sure about that last one).
The application's instance and the container are flushed during tearDown()
so the error would be logical if someone would try to use them after that, but I don't understand WHO would do that.
This is your change from 0.22 to 0.23 https://github.com/mikeerickson/phpunit-pretty-result-printer/compare/0.22.0...0.23.0, so I GUESS that it is getting the exception message that somehow try to use the exception handler (which has a 'render' method), but exception instances are not linked to the application's instance...
I will investigate further tomorrow at work, I'm pretty sure actually that it will end up being a weird side-effect, totally not related to your package...
Fixed. See PR https://github.com/mikeerickson/phpunit-pretty-result-printer/pull/130
I still don't understand why, when the exception was thrown from within Laravel, this is its error handler (instead of PHPUnit's) that is called...
When the exception wasn't thrown from within Laravel, it would just print Undefined index:
(the actual error) instead of the BindingResolutionException
.
While we are at it, I noticed a coloring bug in the displayed messages: the remainder of lines after the first hyphen are colored in green (see attached image).
Lines that follow are colored in white as usual.
Hello, and first of all thanks for this package, the display is indeed much prettier than PHPUnit's default one !
However version 0.23.x introduced a bug with Laravel when it must display an exception that happended during the test: it can't resolve the exception handler and display the following error instead (twice).
Doesn't happen with version 0.22.
Same result with Laravel 5.7.6 or 5.7.9, and PHPUnit 7.3.x or 7.4.0, and again, it work great with v0.22, but not with v0.23.0 and v0.23.2.
Thanks for your time !