Solución: Error en Bitbucket Pipelines al ejecutar pruebas de Laravel con PHPUnit y Paratest

Al ejecutar en el pipeline los tests unitarios aparece un error de memoria

In WorkerCrashedException.php line 41:
                                                                               
  The test "PARATEST='1' TEST_TOKEN='7' UNIQUE_TEST_TOKEN='7_66f1d266ad6eb' t  
  ests/Feature/PruebasTest.php" failed.                               
                                                                               
  Exit Code: 255(Unknown error)                                                
                                                                               
  Working directory: /opt/atlassian/pipelines/agent/build                      
                                                                               
  Output:                                                                      
  ================                                                             
                                                                               
  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to all  
  ocate 16777248 bytes) in /opt/atlassian/pipelines/agent/build/vendor/maennc  
  hen/zipstream-php/src/File.php on line 332         

La solución es agregar un elemento <ini> al archivo de configuración de PHPUnit phpunit.xml con el valor memory_limit para aumentar la asignación de memoria, en mi caso lo aumenté a 512M

<php>
    <ini name="memory_limit" value="512M" />
</php>

Dando como resultado el archivo:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         colors="true"
>
    <testsuites>
        <testsuite name="Unit">
            <directory>tests/Unit</directory>
        </testsuite>
        <testsuite name="Feature">
            <directory>tests/Feature</directory>
        </testsuite>
    </testsuites>
    <source>
        <include>
            <directory>app</directory>
        </include>
    </source>
    <php>
        <ini name="memory_limit" value="512M" />
        <env name="APP_ENV" value="testing"/>
        <env name="BCRYPT_ROUNDS" value="4"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>
        <env name="MAIL_MAILER" value="array"/>
        <env name="PULSE_ENABLED" value="false"/>
        <env name="QUEUE_CONNECTION" value="sync"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="TELESCOPE_ENABLED" value="false"/>
    </php>
</phpunit>
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments