From 6a457991769552f9117e927371895f6d080a7d5d Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Mon, 24 May 2021 22:39:01 +0200 Subject: [PATCH] WIP|Add mutation testing Allows to check whether tests cover code manipulation. WIP: * Fix existing issues Resolves: #27 --- .github/workflows/ci.yaml | 52 +++++++++++++++++++++++++++++++++++++++ composer.json | 3 ++- infection.json.dist | 13 ++++++++++ phpunit.xml.dist | 1 + 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 infection.json.dist diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 42249e1..7bd51ef 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,6 +23,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "${{ matrix.php-version }}" - name: PHP lint @@ -44,6 +45,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "${{ matrix.php-version }}" - name: Get Composer Cache Directory @@ -84,6 +86,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "${{ matrix.php-version }}" - name: Get Composer Cache Directory @@ -117,6 +120,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "7.4" - name: Install xmllint @@ -154,6 +158,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "7.4" - name: Get Composer Cache Directory @@ -191,6 +196,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "${{ matrix.php-version }}" - name: Get Composer Cache Directory @@ -232,6 +238,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "${{ matrix.php-version }}" - name: Get Composer Cache Directory @@ -272,6 +279,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "${{ matrix.php-version }}" - name: Get Composer Cache Directory @@ -322,6 +330,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "${{ matrix.php-version }}" - name: Get Composer Cache Directory @@ -354,6 +363,47 @@ jobs: export typo3DatabasePassword="root" ./vendor/bin/phpunit --testdox + mutationtesting: + runs-on: ubuntu-latest + needs: + - tests-sqlite-TYPO3-v10 + strategy: + matrix: + php-version: + - '7.4' + typo3-version: + - '^10.4' + steps: + - uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php-version }}" + coverage: pcov + ini-values: pcov.directory=Classes + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Switch to expected TYPO3 Version + run: composer require --prefer-dist --no-progress --update-with-all-dependencies "typo3/cms-backend:${{ matrix.typo3-version }}" "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-dashboard:${{ matrix.typo3-version }}" + + - name: PHPUnit Tests + run: ./vendor/bin/infection --show-mutations --min-msi=90 --min-covered-msi=92 --no-progress -j$(nproc) + code-quality-TYPO3-v10: runs-on: ubuntu-latest needs: @@ -370,6 +420,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "${{ matrix.php-version }}" - name: Get Composer Cache Directory @@ -410,6 +461,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: + coverage: none php-version: "${{ matrix.php-version }}" - name: Get Composer Cache Directory diff --git a/composer.json b/composer.json index 16a96f7..cbb3800 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,8 @@ "phpspec/prophecy-phpunit": "^2.0", "typo3/testing-framework": "^6.8.2", "saschaegerer/phpstan-typo3": "^0.13.1", - "symplify/easy-coding-standard": "^9.3" + "symplify/easy-coding-standard": "^9.3", + "infection/infection": "^0.23.0" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/infection.json.dist b/infection.json.dist new file mode 100644 index 0000000..f751148 --- /dev/null +++ b/infection.json.dist @@ -0,0 +1,13 @@ +{ + "source": { + "directories": [ + "Classes" + ] + }, + "logs": { + "text": ".Build\/infection" + }, + "mutators": { + "@default": true + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 858b92f..f1bbdbe 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,6 +8,7 @@ colors="true" convertErrorsToExceptions="true" convertWarningsToExceptions="true" + executionOrder="default" forceCoversAnnotation="false" processIsolation="false" stopOnError="false"