php - 当我打开 Xdebug 时,phpunit 引导设置不起作用
问题描述
我在使用 Xdebug 和 PHPUnit 时遇到问题。
因为我想使用AspectMock,所以我在 phpunit.xml 配置中创建了引导程序,它运行良好。
但是,当我尝试打开 Xdebug 以生成覆盖率报告时,它并没有使用我的引导设置。(我不确定是因为它没有读取或引导设置被覆盖)
我不知道为什么或在哪里可以找到错误。
这是结果示例(我已经转储了我的模拟):(与 -c phpunit.xml 相同)
$vendor/bin/phpunit test.php
array: [
"status" => "successed",
"data" => ["test" => "test"]
]
$vendor/bin/phpunit --coverage-html build/coverage test.php(因为数据没有模拟)
array: [
"status" => "failed",
"data" => []
]
php.ini
[Xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_enable=On
$php -v
PHP 7.1.16 (cli) (built: Mar 31 2018 02:59:59) (NTS)
版权所有 (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2 .6.1,版权所有 (c) 2002-2018,作者 Derick Rethans
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="test">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
</phpunit>
测试/bootstrap.php
<?php
include __DIR__.'/../vendor/autoload.php'; // composer autoload
$kernel = \AspectMock\Kernel::getInstance();
$kernel->init([
'debug' => true,
'includePaths' => [__DIR__.'/../app'],
'cacheDir' => __DIR__.'/cache/aspectmock',
'excludePaths' => [
__DIR__,
__DIR__ . '../../vendor',
],
]);
解决方案
推荐阅读
- kdb - 在不使用全局变量的情况下附加数据
- android - webapp2 - 同时服务于网站和安卓应用
- vue.js - Vue,为什么花括号消息数据不显示?
- python - Elastic Beanstalk 上 Django/Celery 的权限问题
- java - spring boot 并行传出请求的最佳实践是什么?
- android - 什么布局最好根据坐标设置其内部视图
- python - 如何在需要时退出循环?
- google-cloud-dataflow - BeamSQL 中是否有“LIKE”的解决方法?
- ios - Swift:完成关闭永远不会执行?
- python - 将列表分解为较小的重复元素列表,并保留原始顺序(Python)