php – 仅生成刚刚测试过的内容

每次我运行一个类或整个文件夹的单元测试时,phpunit会为整个系统生成覆盖,因为它是在phpunit.xml中配置的.
这很糟糕,因为它需要更长的时间并耗尽 PHP的内存.

我的phpunit.xml

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
    backupGlobals               = "false"
    backupStaticAttributes      = "false"
    colors                      = "true"
    convertErrorsToExceptions   = "true"
    convertNoticesToExceptions  = "true"
    convertWarningsToExceptions = "true"
    processIsolation            = "false"
    stopOnFailure               = "false"
    syntaxCheck                 = "false"
    bootstrap                   = "Bootstrap.php" >

    <testsuites>
        <testsuite name="Application Module Suite Test">
            <directory>./Module1Test</directory>
            <directory>./Module2Test</directory>
            <directory>./Module3Test</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory>../module/Module1</directory>
            <directory>../module/Module2</directory>
            <directory>../module/Module3</directory>
        </whitelist>
    </filter>

</phpunit>

有没有办法动态地生成我现在正在测试的内容?


对于下面的命令,我想仅为Controller / ExampleController.php路径生成覆盖.

phpunit Controller/ExampleController.php --coverage-html ~/Desktop/tests

我正在使用PHPUnit 4.8和3.7,Sublime Text Editor,应用程序正在使用Zend Framework 2.

从PHPUnit 5.6手册:

The @covers annotation (see Table B.1) can be used in the test code to specify which method(s) a test method wants to test. If provided,only the code coverage information for the specified method(s) will be considered. Example 11.2 shows an example.

请参阅此链接以获取示例:https://phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.specifying-covered-methods.examples.BankAccountTest.php

这对你的场景有用吗?

相关文章

文章浏览阅读8.4k次,点赞8次,收藏7次。SourceCodester Onl...
文章浏览阅读3.4k次,点赞46次,收藏51次。本文为大家介绍在...
文章浏览阅读1.1k次。- php是最优秀, 最原生的模板语言, 替代...
文章浏览阅读1.1k次,点赞18次,收藏15次。整理K8s网络相关笔...
文章浏览阅读1.2k次,点赞22次,收藏19次。此网络模型提供了...
文章浏览阅读1.1k次,点赞14次,收藏19次。当我们谈论网络安...