加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 13:18:24 所属栏目:PHP教程 来源:网络整理
导读:每次我运行一个类或整个文件夹的单元测试时,phpunit会为整个系统生成覆盖,因为它是在phpunit.xml中配置的. 这很糟糕,因为它需要更长的时间并耗尽 PHP的内存. 我的phpunit.xml !-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html --
每次我运行一个类或整个文件夹的单元测试时,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

这对你的场景有用吗?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读