Search code examples
phpphpunitsymfony4mutation-testinginfection

Infection Throws Exeption, but why, and how to handle it?


The Task is that the error does bot explain that problem right.

The Error:

Project tests must be in a passing state before running Infection.
Infection runs the test suite in a RANDOM order. Make sure your tests do not have hidden dependencies.

You can add these attributes to phpunit.xml to check it:

If you don't want to let Infection run tests in a random order, set the executionOrder to some value, for example

Check the executed command to identify the problem: '/usr/bin/php7.2' '-d' 'zend_extension=xdebug.so' '/mnt/e/dev/bin/phpunit' '--configuration' '/mnt/e/dev/var/infection/
infection/phpunitConfiguration.initial.infection.xml' '-vvv'
PHPUnit reported an exit code of 143.
Refer to the PHPUnit's output below:
STDERR:

Cannot load Xdebug - it was already loaded

What i try is simple to execute follow statement:

vendor/bin/infection --threads=10 --only-covered

But when I try that statement that explained in that error, the tests will run successfully, but that is only my unit tests without the mutation-testing.

Here is an abstract of phpunit tag in my phpunit.xml.dist

<phpunit .... backupGlobals="false" colors="false" bootstrap="/mnt/e/dev/RESTler/config/bootstrap.php" executionOrder="random" resolveDependencies="true" cacheResult="false" stopOnFailure="true" stderr="false" .../>

The Versions are:

  • PHPUnit version: 7.5.15
  • PHP 7.2.22-1+ubuntu18.04.1+deb.sury.org+1
  • Infection - PHP Mutation Testing Framework 0.14.2
  • Symfony Framework 4.2

has anyone a hint of what I can try or where my error is?


Solution

  • After my long Jurney i found something out. But dont why it dosnt work with my configuration.

    That was the right statement for me, after i remove the xdebug.so from my php.ini

    infection --threads=10 --only-covered --initial-tests-php-options='-d zend_extension=xdebug.so'
    

    I thought it would be enough but then came the memory_limit problem, that cam be fixed on the same way

    infection --threads=10 --only-covered --initial-tests-php-options='-d zend_extension=xdebug.so -d memory_limit=-1'
    

    Now it Runs and i have some todos :)

    .: killed, M: escaped, S: uncovered, E: fatal error, T: timed out

    .........M..MMMMMMM.M.M.MMM.MMMM.M.MMMMMMMM.MMMM.M (50 / 89) .....MM................MMMMMMM.MMMM.... (89 / 89)

    89 mutations were generated:

      45 mutants were killed
    
       0 mutants were not covered by tests
    
      44 covered mutants were not detected
    
       0 errors were encountered
    
       0 time outs were encountered
    

    Metrics:

       Mutation Score Indicator (MSI): 50%
       Mutation Code Coverage: 100%
       Covered Code MSI: 50%
    

    if somebody use phpdbg instead of xdebug and has that memory_limit issue, for me it has work if i had overwrite the new php.ini for phpdbg in my /etc/php/7.3/phpdbg/php.ini

    I hope this post here helps someone else once again. I do not delete it first. Maybe one day another mod.