私は phpstorm を使用しており、laravel アプリでいくつかのテストを作成しました。phpunit.xml
ほぼデフォルトです。
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
</php>
</phpunit>
私のテストの終わりに、次のエラーが表示されます。
Time: 00:15.742, Memory: 58.00 MB
OK (26 tests, 69 assertions)
Generating code coverage report in Clover XML format ... syntax error, unexpected '-', expecting '{'
Process finished with exit code 2
どこから見始めたらいいのかわからない。どんな助けにも感謝します!
アップデート:
HTMLレポートを生成しようとすることによる同じ問題
❯ .\vendor\bin\phpunit --coverage-html ./coverage.html
PHPUnit 9.5.5 by Sebastian Bergmann and contributors.
............................ 28 / 28 (100%)
Time: 00:23.702, Memory: 74.00 MB
OK (28 tests, 125 assertions)
Generating code coverage report in HTML format ... syntax error, unexpected '-', expecting '{'
更新 2:
縮小された最小限の再現テスト ケースを実行します。
class MinimalTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function test_example()
{
$response = $this->get('https://google.com');
$response->assertStatus(200);
}
}
❯ .\vendor\bin\phpunit --filter MinimalTest --coverage-html ./coverage.html
❯ .\vendor\bin\phpunit --debug --filter MinimalTest --coverage-html ./coverage.html
PHPUnit 9.5.5 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.16 with Xdebug 3.0.4
Configuration: C:\Users\***\localGit\xampp\htdocs\oneup\app\phpunit.xml
Test 'Tests\Feature\MinimalTest::test_example' started
Test 'Tests\Feature\MinimalTest::test_example' ended
Time: 00:01.242, Memory: 42.00 MB
OK (1 test, 1 assertion)
Generating code coverage report in HTML format ... syntax error, unexpected '-', expecting '{'