【问题标题】:Configure XDebug code coverage for an external project为外部项目配置 XDebug 代码覆盖率
【发布时间】:2017-10-24 18:39:31
【问题描述】:

我有两个 php 项目:ProjectA 和 ProjectA-Test。 ProjectA 包含应用程序的所有类和方法,而 ProjectA-Test 包含这些类的 PHPUnit 测试。

我正在尝试在 Jenkins 中设置代码覆盖率报告以确定这些测试的覆盖率。测试都运行正常,但是代码覆盖率报告是针对 ProjectA-Test,而不是 ProjectA。

我正在使用 ant 来触发 PHPUnit 测试:

<target name="phpunit" description="Run unit tests with PHPUnit">
   <exec executable="phpunit" failonerror="true" />
</target>

我的 phpunit.xml 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit strict="true" verbose="true">
    <testsuites>
        <testsuite name="ProjectA-Test">
            <directory suffix='.php'>./src/</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">../ProjectA</directory>
        </whitelist>
    </filter>

    <logging>
        <log type="coverage-html" target="build/coverage" title="Project A Test" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70"/>
        <log type="junit" target="build/logs/phpunit.xml" logIncompleteSkipped="false"/>
    </logging>

</phpunit>

目录结构如下:

.
├── ProjectA
|   └── <PHP Files being tested>
└── ProjectA-Test
    ├── src
    |   └── <Unit test are all here>
    ├── build
    |   ├── logs
    |   |   └── phpunit.xml
    |   └── coverage
    |       └── <coverage reports are saved here>
    ├── phpunit.xml
    └── build.xml

每个测试都有这样的注释:

/**
 * @covers \ProjectA\ClassBeingTested::method_being_tested()
 */

如何配置 XDebug 以设置代码覆盖率来评估 ProjectA 类,而不是 ProjectA-Test 文件?

【问题讨论】:

    标签: jenkins ant phpunit xdebug


    【解决方案1】:

    问题解决了。我在 phpunit.xml 的白名单部分有错字

    【讨论】:

      猜你喜欢
      • 2018-05-07
      • 2021-04-16
      • 1970-01-01
      • 1970-01-01
      • 2012-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多