laravelphpunit

Memory exhausted while running phpunit


I'm using pest PHP testing framework for unit testing in laravel. Memory is getting exhausted each time when my test cases are run. How can I increase my memory limit for test cases? Below I'm attaching a screenshot of my terminal output enter image description here


Solution

  • You can increase the memory of PHP, but depending on how many tests you have, you should look into if you have memory leaks or data being kept in memory that should not.

    php -d memory_limit=2048M ./vendor/bin/phpunit
    

    Which is in current phpunit versions same as:

    php -d memory_limit=2048M vendor/phpunit/phpunit/phpunit
    

    Or try short-form:

    php -d memory_limit=2048M artisan test