diff --git a/.gitignore b/.gitignore index cdd7d7b..a45c104 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,12 @@ /.phpunit.result.cache +# ------------------------------------------------------------------------------ +### Infection +# ------------------------------------------------------------------------------ +/infection.json + + # ------------------------------------------------------------------------------ ### PHP Coding Standards Fixer # ------------------------------------------------------------------------------ diff --git a/CHANGELOG.md b/CHANGELOG.md index c32cb66..78ad0c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Common and useful classes, methods, exceptions etc. 1. Phing > remove old and unused tools 2. Phing > configuration > minor updates +3. Implement Mutation Testing Framework (infection/infection package) # 1.0.1 diff --git a/composer.json b/composer.json index c19df0f..f39c07b 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.14", + "infection/infection": "^0.11.4", "phpunit/phpunit": "^8.0", "sebastian/phpcpd": "^4.1", "squizlabs/php_codesniffer": " ^2.9" diff --git a/docs/Development.md b/docs/Development.md index 7f60fb0..211e9f4 100644 --- a/docs/Development.md +++ b/docs/Development.md @@ -112,6 +112,46 @@ docker-compose run --rm phpunit --verbose --no-coverage I have to use [squizlabs/php_codesniffer](https://packagist.org/packages/squizlabs/php_codesniffer) `^2.9` instead of `^3.3`, because [Phing doesn't support 3.x PHP_CodeSniffer](https://github.com/phingofficial/phing/issues/716). +# Mutation Tests + +Served by [Infection — Mutation Testing Framework](https://infection.github.io). + +### Running tests + +```bash +docker-compose exec php vendor/bin/infection --threads=5 +``` + +or + +```bash +docker-compose exec php phing -f phing/tests.xml test:infection +``` + +### Result of testing + +##### Terminal + +Example of output: +```bash +125 mutations were generated: + 105 mutants were killed + 3 mutants were not covered by tests + 5 covered mutants were not detected + 0 errors were encountered + 12 time outs were encountered + +Metrics: + Mutation Score Indicator (MSI): 93% + Mutation Code Coverage: 97% + Covered Code MSI: 95% +``` + +##### Stored in `build/reports/infection` directory + +* `build/reports/infection/infection-log.txt` +* `build/reports/infection/summary-log.txt` + # Other Rebuild project and run tests by running command: diff --git a/infection.json.dist b/infection.json.dist new file mode 100644 index 0000000..06b8a4c --- /dev/null +++ b/infection.json.dist @@ -0,0 +1,13 @@ +{ + "timeout": 10, + "source": { + "directories": [ + "src" + ] + }, + "logs": { + "text": "build/reports/infection/infection-log.txt", + "summary": "build/reports/infection/summary-log.txt", + "debug": "build/reports/infection/debug-log.txt" + } +} diff --git a/phing/properties.dist b/phing/properties.dist index d1aa6d2..3a49281 100644 --- a/phing/properties.dist +++ b/phing/properties.dist @@ -77,5 +77,7 @@ tests.database = ${dir.data.temporary}/database.sqlite # Paths of frameworks used to run tests: # - PHPUnit (unit tests) +# - Infection (mutation tests) # -tests.phpunit.command = ./vendor/bin/phpunit --verbose +tests.phpunit.command = ./vendor/bin/phpunit --verbose --no-coverage +tests.mutation.command = ./vendor/bin/infection --threads=5 diff --git a/phing/tests.xml b/phing/tests.xml index a03b709..3f97f01 100644 --- a/phing/tests.xml +++ b/phing/tests.xml @@ -48,7 +48,7 @@ @@ -74,6 +74,11 @@ + + + + +