PHP感染所有突变体均未纳入测试

时间:2018-10-17 02:43:57

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

我正在尝试将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测试套件,但是我在其他地方找不到关于此问题的任何讨论。

如果有人有任何想法让我知道。

1 个答案:

答案 0 :(得分:0)

这个问题在我身上!绕圈跑了几个小时才发现这是你自己的错,这是一个真正的痛苦。

我已经设置了phpunit配置选项forceCoversAnnotation,使得它

  

“仅针对使用@Covers的测试记录代码覆盖率   @Covers中记录的注释。”

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