mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 01:31:45 +01:00
Implement Mutation Testing Framework (infection/infection package)
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -30,6 +30,12 @@
|
||||
/.phpunit.result.cache
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
### Infection
|
||||
# ------------------------------------------------------------------------------
|
||||
/infection.json
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
### PHP Coding Standards Fixer
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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:
|
||||
|
||||
13
infection.json.dist
Normal file
13
infection.json.dist
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
<!-- Test target -->
|
||||
<target name="build:test"
|
||||
depends="test:phpunit"
|
||||
depends="test:phpunit, test:infection"
|
||||
/>
|
||||
|
||||
<!-- Symfony2 code sniffer -->
|
||||
@@ -74,6 +74,11 @@
|
||||
<exec command="${tests.phpunit.command}" passthru="true"/>
|
||||
</target>
|
||||
|
||||
<!-- Run mutation testing -->
|
||||
<target name="test:infection" depends="build:prepare">
|
||||
<exec command="${tests.mutation.command}" passthru="true"/>
|
||||
</target>
|
||||
|
||||
<!-- Project build clean -->
|
||||
<target name="build:clean">
|
||||
<if>
|
||||
|
||||
Reference in New Issue
Block a user