0

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

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

4

1 回答 1

1

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

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

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

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

于 2018-10-17T17:21:24.907 回答