I would like to know if it's possible to generate a code coverage from one single file. Let's say I am writing tests for a class BankAccount, it would be handy if i could from command line do something like

phpunit BankAccount.php --create-coverage-for-this-file-only

Does anyone have experience experience with this?

Thaks

没有正确的解决方案

其他提示

Using the XML file, you can include the files or directories you want to process, and exclude the ones you do not. PHPUnit Manual Entry

<filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <file>BankAccount.php</file>
        <directory suffix=".class">.</directory>
        <directory suffix=".fn">.</directory>
        <directory suffix=".php">.</directory>
        <exclude>
            <directory>ExternalLibraries</directory>
        </exclude>
    </whitelist>
</filter>

Yes you can do this with the --filter option.

phpunit -d xdebug.profiler_enable=On --coverage-html tests/_report/ --filter=BankAccount
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top