Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a BindingResolutionException on Pest with coverage #253

Closed
manuglopez opened this issue Jan 9, 2021 · 6 comments
Closed

Getting a BindingResolutionException on Pest with coverage #253

manuglopez opened this issue Jan 9, 2021 · 6 comments

Comments

@manuglopez
Copy link

Hello Good job with pest, but I`m having a problem with Pest code coverage in mac.

I`m running my app in

  • Valet
  • Php 7.49
  • Xdebug 3.0.2

Pest is running test correctly but with xdebug 3.0.2 is throwing this error (only in coverage mode).

Uninstalling Pest and running code coverage with phpunit does work, and phpunit show coverage.

¿Is this a Bug?

Thanks.

PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:1038
Stack trace:
#0 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(839): Illuminate\Container\Container->notInstantiable('Illuminate\Cont...')
#1 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(712): Illuminate\Container\Container->build('Illuminate\Cont...')
#2 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve('Illuminate\Cont...', Array, true)
#3 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\Foundation\Application->resolve('Illuminate\Cont...', Array)
#4 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\Co in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1038

Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1038

Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1038

Call Stack:
3.8439 39657320 1. Illuminate\Foundation\Bootstrap\HandleExceptions->handleException($e = class Pest\Exceptions\ShouldNotHappen { protected $message = '\nThis should not happen - please create an new issue here: https://github.com/pestphp/pest.\n\n- Issue: Coverage not found in path: /Users/mgl/Code/avapp/vendor/pestphp/.temp/coverage.php.\n- PHP version: 7.4.9\n- Operating system: Darwin'; private ${Exception}string = ''; protected $code = 1; protected $file = '/Users/mgl/Code/avapp/vendor/pestphp/pest/src/Exceptions/ShouldNotHappen.php'; protected $line = 38; private ${Exception}trace = [0 => [...], 1 => [...], 2 => [...], 3 => [...], 4 => [...]]; private ${Exception}previous = class Exception { protected $message = 'Coverage not found in path: /Users/mgl/Code/avapp/vendor/pestphp/.temp/coverage.php.'; private $string = ''; protected $code = 0; protected $file = '/Users/mgl/Code/avapp/vendor/pestphp/pest/src/Exceptions/ShouldNotHappen.php'; protected $line = 38; private $trace = [...]; private $previous = NULL }; public $xdebug_message = '\nPest\Exceptions\ShouldNotHappen: \nThis should not happen - please create an new issue here: https://github.com/pestphp/pest.\n\n- Issue: Coverage not found in path: /Users/mgl/Code/avapp/vendor/pestphp/.temp/coverage.php.\n- PHP version: 7.4.9\n- Operating system: Darwin in /Users/mgl/Code/avapp/vendor/pestphp/pest/src/Exceptions/ShouldNotHappen.php on line 38\n\nCall Stack:\n 0.0004 400896 1. {main}() /Users/mgl/Code/avapp/vendor/pestphp/pest/bin/pest:0\n 0.0006 401216 2. {closure:/U' }) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:0
3.8442 39658536 2. Illuminate\Foundation\Bootstrap\HandleExceptions->renderForConsole($e = class Illuminate\Contracts\Container\BindingResolutionException { protected $message = 'Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.'; private ${Exception}string = ''; protected $code = 0; protected $file = '/Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php'; protected $line = 1038; private ${Exception}trace = [0 => [...], 1 => [...], 2 => [...], 3 => [...], 4 => [...], 5 => [...], 6 => [...], 7 => [...]]; private ${Exception}previous = NULL; public $xdebug_message = '\nIlluminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1038\n\nCall Stack:\n 3.8439 39657320 1. Illuminate\Foundation\Bootstrap\HandleExceptions->handleException($e = class Pest\Exceptions\ShouldNotHappen { protected $message = '\nThis should not happen - please create an new issue here: https://github.com/pestphp' }) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:94
3.8442 39658536 3. Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler() /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:108
3.8442 39658536 4. Illuminate\Foundation\Application->make($abstract = 'Illuminate\Contracts\Debug\ExceptionHandler', $parameters = ???) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:164
3.8442 39658536 5. Illuminate\Foundation\Application->make($abstract = 'Illuminate\Contracts\Debug\ExceptionHandler', $parameters = []) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:781
3.8443 39658536 6. Illuminate\Foundation\Application->resolve($abstract = 'Illuminate\Contracts\Debug\ExceptionHandler', $parameters = [], $raiseEvents = ???) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:651
3.8443 39658536 7. Illuminate\Foundation\Application->resolve($abstract = 'Illuminate\Contracts\Debug\ExceptionHandler', $parameters = [], $raiseEvents = TRUE) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
3.8443 39658536 8. Illuminate\Foundation\Application->build($concrete = 'Illuminate\Contracts\Debug\ExceptionHandler') /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:712
3.8443 39658632 9. Illuminate\Foundation\Application->notInstantiable($concrete = 'Illuminate\Contracts\Debug\ExceptionHandler') /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:839

Whoops\Exception\ErrorException

Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:1038
Stack trace:
#0 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(839): Illuminate\Container\Container->notInstantiable('Illuminate\Cont...')
#1 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(712): Illuminate\Container\Container->build('Illuminate\Cont...')
#2 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve('Illuminate\Cont...', Array, true)
#3 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\Foundation\Application->resolve('Illuminate\Cont...', Array)
#4 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\Co

at vendor/laravel/framework/src/Illuminate/Container/Container.php:1038
1034▕ } else {
1035▕ $message = "Target [$concrete] is not instantiable.";
1036▕ }
1037▕
➜ 1038▕ throw new BindingResolutionException($message);
1039▕ }
1040▕
1041▕ /**
1042▕ * Throw an exception for an unresolvable primitive.

  +1 vendor frames 

2 [internal]:0
Whoops\Run::handleShutdown()
PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:1038
Stack trace:
#0 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(839): Illuminate\Container\Container->notInstantiable('Illuminate\Cont...')
#1 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(712): Illuminate\Container\Container->build('Illuminate\Cont...')
#2 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve('Illuminate\Cont...', Array, true)
#3 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\Foundation\Application->resolve('Illuminate\Cont...', Array)
#4 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\Co in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1038

Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1038

Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1038

Call Stack:
3.9446 39729744 1. Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown() /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:0
3.9450 39748552 2. Illuminate\Foundation\Bootstrap\HandleExceptions->handleException($e = class Symfony\Component\ErrorHandler\Error\FatalError { private $error = ['type' => 1, 'message' => 'Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:1038\nStack trace:\n#0 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(839): Illuminate\Container\Container->notInstantiable('Illuminate\\Cont...')\n#1 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Contain', 'file' => '/Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php', 'line' => 1038]; protected $message = 'Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:1038\nStack trace:\n#0 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php(839): Illuminate\Container\Container->notInstantiable('Illuminate\\Cont...')\n#1 /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Contain'; private ${Error}string = ''; protected $code = 0; protected $file = '/Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php'; protected $line = 1038; private ${Error}trace = [0 => [...], 1 => [...], 2 => [...]]; private ${Error}previous = NULL }) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:130
3.9451 39760592 3. Illuminate\Foundation\Bootstrap\HandleExceptions->renderForConsole($e = class Illuminate\Contracts\Container\BindingResolutionException { protected $message = 'Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.'; private ${Exception}string = ''; protected $code = 0; protected $file = '/Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php'; protected $line = 1038; private ${Exception}trace = [0 => [...], 1 => [...], 2 => [...], 3 => [...], 4 => [...], 5 => [...], 6 => [...], 7 => [...], 8 => [...]]; private ${Exception}previous = NULL; public $xdebug_message = '\nIlluminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1038\n\nCall Stack:\n 3.9446 39729744 1. Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown() /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:0\n 3.9450 39748552 2. Illuminate\Foundation' }) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:94
3.9451 39760592 4. Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler() /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:108
3.9451 39760592 5. Illuminate\Foundation\Application->make($abstract = 'Illuminate\Contracts\Debug\ExceptionHandler', $parameters = ???) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:164
3.9451 39760592 6. Illuminate\Foundation\Application->make($abstract = 'Illuminate\Contracts\Debug\ExceptionHandler', $parameters = []) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:781
3.9451 39760592 7. Illuminate\Foundation\Application->resolve($abstract = 'Illuminate\Contracts\Debug\ExceptionHandler', $parameters = [], $raiseEvents = ???) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:651
3.9451 39760592 8. Illuminate\Foundation\Application->resolve($abstract = 'Illuminate\Contracts\Debug\ExceptionHandler', $parameters = [], $raiseEvents = TRUE) /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:796
3.9451 39760592 9. Illuminate\Foundation\Application->build($concrete = 'Illuminate\Contracts\Debug\ExceptionHandler') /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:712
3.9451 39760688 10. Illuminate\Foundation\Application->notInstantiable($concrete = 'Illuminate\Contracts\Debug\ExceptionHandler') /Users/mgl/Code/avapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:839

@manuglopez manuglopez changed the title Getting a BidingResolutionException on Pest with coverage Getting a BindingResolutionException on Pest with coverage Jan 9, 2021
@nunomaduro
Copy link
Member

@manuglopez Try this: XDEBUG_MODE=coverage ./vendor/bin/pest --coverage.

@manuglopez
Copy link
Author

@manuglopez Try this: XDEBUG_MODE=coverage ./vendor/bin/pest --coverage.

This is working. Thanks @nunomaduro, but I wonder why in my Mac I have to pass xdebug_mode and in Ubuntu it works without passing mode.

@owenvoke
Copy link
Member

owenvoke commented Jan 9, 2021

@manuglopez, on Ubuntu is the coverage option in the php.ini configuration? 🤔 If you run php -i | grep xdebug.mode it should show the option.

@manuglopez
Copy link
Author

on Ubuntu is the coverage option in the php.ini configuration? 🤔 If you run php -i | grep xdebug.mode it should show the option.

Probably is there, I can't tell you now but, I have modified xdebug.mode section in php.ini and now all is working with no need to setup enviroment variable to coverage as @nunomaduro wisely stated to me in the post before.

Anyway, the main difference between my two setups is the xdebug version, in Ubuntu I think I have version 2 and in mac Version 3.

Xdebug 3 includes major changes in functionality compared to Xdebug 2. The primary way how you turn on functionality is through the new xdebug.mode PHP configuration setting. This made it possible to massively increase performance in many of Xdebug's sub systems as Xdebug is now much more conservative in which hooks are enabled.

And by default mode is develop

There has been many changes in Xdebug configuration from version 2 to 3.

https://xdebug.org/docs/upgrade_guide#changed-xdebug.coverage_enable

@owenvoke
Copy link
Member

owenvoke commented Jan 9, 2021

Ah, yeah. I was going to ask if the xdebug.mode wasn't set to coverage, whether you were using Xdebug 2. 👍🏻 I wonder if there's a good way of covering this in the docs or something.

@nunomaduro
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants