我正在使用 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 '{'