【问题标题】:PHP Infection all mutants were not covered by testsPHP 感染所有突变体都没有被测试覆盖
【发布时间】:2019-03-21 15:25:00
【问题描述】:

我正在尝试将infection/infection php 突变测试库实施到我的一个新项目中。我设置了一些测试都通过了,然后进行了感染。

感染返回以下内容:

You are running Infection with xdebug enabled.
    ____      ____          __  _
   /  _/___  / __/__  _____/ /_(_)___  ____ 
   / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
 _/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
/___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

Running initial test suite...

PHPUnit version: 7.4.0

   23 [============================] < 1 sec

Generate mutants...

Processing source code files: 3/3
Creating mutated files and processes: 14/14
.: killed, M: escaped, S: uncovered, E: fatal error, T: timed out

SSSSSSSSSSSSSS                                       (14 / 14)

14 mutations were generated:
       0 mutants were killed
      14 mutants were not covered by tests
       0 covered mutants were not detected
       0 errors were encountered
       0 time outs were encountered

Metrics:
         Mutation Score Indicator (MSI): 0%
         Mutation Code Coverage: 0%
         Covered Code MSI: 0%

Please note that some mutants will inevitably be harmless (i.e. false positives).

Time: 1s. Memory: 10.00MB

当我更深入地挖掘我的infection-log.txt 时,我发现许多未发现的突变体都是针对Function Signature Visibility mutator

我遇到的问题是我的测试确实涵盖了这些方法。我手动将我的一些方法从公共更改为受保护,重新运行了我的 phpunit 测试并且测试失败了。我真的不知道从哪里开始。我有一种预感,感染无法正确检测到我的 phpunit 测试套件,但我在其他地方找不到任何关于此问题的讨论。

如果有人有任何想法,请告诉我。

【问题讨论】:

  • 是否有日志文件,或者更详细的模式来显示突变后通过的所有测试?
  • @FrankerZ 只有我链接到的infection-log.txt。我确实告诉感染会生成其他日志文件以防万一,但它们都没有为我提供任何其他信息。 PHPUnit 的 --verbose 模式似乎也没有做任何事情。

标签: php unit-testing phpunit mutation-testing infection


【解决方案1】:

这个问题是我的!兜兜转转几个小时才发现这是你自己的错,真的很痛苦。

我已经设置了 phpunit 配置选项forceCoversAnnotation,这样就可以了

"代码覆盖率只会记录在使用@Covers 的测试中 @Covers 中记录的注释。”

我从来没有使用@Covers 注释,我认为我通常也不会。对于令人困惑的问题,我深表歉意,谢谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-04
    • 2014-01-05
    • 2016-02-27
    • 2020-01-14
    • 2016-05-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多