Skip to content

Commit

Permalink
+ infection.json5
Browse files Browse the repository at this point in the history
* set `executionOrder` to `random` @ phpunit.xml
* add attribute `#[CoversClass(BaseQuery::class)]` @ `Tests\Feature\App\Http\PostsQuery`
@ be

+ step to run `infection` @ job `phpunit-infection` @ .github/workflows/be_base.yml
  • Loading branch information
n0099 committed Sep 17, 2024
1 parent 99d1db6 commit e87f758
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/be_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defaults:
run:
working-directory: be
jobs:
phpunit:
phpunit-infection:
runs-on: ${{ inputs.runs-on }}
steps:
- uses: actions/checkout@v4
Expand All @@ -22,12 +22,18 @@ jobs:
coverage: xdebug
# https://github.com/shivammathur/setup-php/blob/2.31.1/README.md#problem-matchers
- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- run: ./vendor/bin/phpunit --coverage-clover clover.xml
- run: >
./vendor/bin/phpunit
--coverage-clover=coverage/clover.xml
--coverage-xml=coverage/coverage-xml
--log-junit=coverage/junit.xml
# https://infection.github.io/guide/command-line-options.html#coverage
- uses: actions/upload-artifact@v4
with:
name: coverage-${{ inputs.runs-on }}-clover.xml
path: be/clover.xml
name: coverage-${{ inputs.runs-on }}
path: be/coverage/clover.xml
compression-level: 9
- run: ./vendor/bin/infection --coverage=coverage --skip-initial-tests

phpstan:
runs-on: ${{ inputs.runs-on }}
Expand Down
10 changes: 10 additions & 0 deletions be/infection.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "vendor/infection/infection/resources/schema.json",
"source": {
"directories": ["."],
"excludes": ["vendor", "tests", ".phpstorm.meta.php", "/_ide_helper.*.php/", "bootstrap/cache/*"]
},
"mutators": {
"@default": true
}
}
1 change: 1 addition & 0 deletions be/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
executionOrder="random"
>
<testsuites>
<testsuite name="Unit">
Expand Down
2 changes: 2 additions & 0 deletions be/tests/Feature/App/Http/PostsQuery/BaseQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
use App\Http\PostsQuery\BaseQuery;
use Barryvdh\Debugbar\LaravelDebugbar;
use Illuminate\Pagination\Cursor;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

#[CoversClass(BaseQuery::class)]
class BaseQueryTest extends TestCase
{
private BaseQuery $sut;
Expand Down

0 comments on commit e87f758

Please sign in to comment.