Skip to content

Commit

Permalink
Merge pull request #4445 from paulbalandan/speedtrap
Browse files Browse the repository at this point in the history
Use speedtrap to document slow tests
  • Loading branch information
paulbalandan authored Mar 21, 2021
2 parents 35bf87c + 8d9f666 commit de8d7f4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

- name: Test with PHPUnit
run: script -e -c "vendor/bin/phpunit -v"
run: script -e -c "vendor/bin/phpunit --color=always"
env:
DB: ${{ matrix.db-platforms }}
TERM: xterm-256color
Expand All @@ -140,7 +140,7 @@ jobs:

coveralls-finish:
needs: [tests]
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"require-dev": {
"codeigniter4/codeigniter4-standard": "^1.0",
"fakerphp/faker": "^1.9",
"johnkary/phpunit-speedtrap": "^3.3",
"mikey179/vfsstream": "^1.6",
"phpstan/phpstan": "0.12.81",
"phpunit/phpunit": "^9.1",
Expand Down
48 changes: 36 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="system/Test/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="system/Test/bootstrap.php"
backupGlobals="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
cacheResultFile="build/.phpunit.cache/test-results"
colors="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./system</directory>
</include>

<exclude>
<directory>./system/Commands/Generators/Views</directory>
<directory>./system/Debug/Toolbar/Views</directory>
Expand All @@ -26,10 +27,12 @@
<file>./system/Config/Routes.php</file>
<file>./system/Test/bootstrap.php</file>
</exclude>

<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>

<testsuites>
<testsuite name="System">
<directory>./tests/system</directory>
Expand All @@ -39,7 +42,28 @@
<directory>./tests/system/Database</directory>
</testsuite>
</testsuites>
<logging/>

<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
<arguments>
<array>
<!-- Number of milliseconds when a test is considered "slow" (Default: 500ms) -->
<element key="slowThreshold">
<integer>500</integer>
</element>
<!-- Number of slow tests included in the report (Default: 10 tests) -->
<element key="reportLength">
<integer>30</integer>
</element>
<!-- Stop execution upon first slow test (Default: false) -->
<element key="stopOnSlow">
<boolean>false</boolean>
</element>
</array>
</arguments>
</listener>
</listeners>

<php>
<env name="XDEBUG_MODE" value="coverage"/>
<server name="app.baseURL" value="http://example.com/"/>
Expand Down

0 comments on commit de8d7f4

Please sign in to comment.