JUnit测试通过,但PIT称该套件不是绿色的 [英] JUnit tests pass but PIT says the suite isn't green

查看:488
本文介绍了JUnit测试通过,但PIT称该套件不是绿色的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试运行PIT突变测试时,我收到以下错误:

While trying to run a PIT mutation test I get the following error:


mutationCoverage failed:所有测试都没有在没有突变的情况下通过计算线覆盖范围。变异测试需要一个绿色套件。

mutationCoverage failed: All tests did not pass without mutation when calculating line coverage. Mutation testing requires a green suite.

当我进行正常的测试构建时,测试运行正常但在运行突变测试阶段时据说失败但没有详细说明原因。我已经了解了 PIT测试常见问题解答中列出的原因,但我仍然不知道可能出现的问题。

The tests run just fine when I do a normal test build but while running the mutation tests phase they supposedly fail but no details are provided as to why. I have gone through the reasons listed on the PIT Testing FAQ but I still have no clue what could be wrong.

我试过:


  • 为任何多线程问题的规则添加-Dthreads = 1选项

  • 找不到任何系统属性,这些属性是唯一失败的情侣测试

  • 正常运行时不会忽略测试

我还应该尝试一些其他的事情吗?或者其他方法来调试可能发生的事情?

What are some other things I should try? Or other ways to debug what could be going on here?

推荐答案

测试在覆盖阶段失败的常见原因是

The common causes of tests failing at the coverage stage are


  1. 正常测试配置中不包括PIT拾取未包含/未包含的测试

  2. 测试依赖于环境测试配置中设置的变量或其他属性,但未在pitest配置中设置

  3. 测试具有在正常测试运行期间未显示的隐藏顺序依赖关系

  4. PIT不喜欢你的技术堆栈中的东西 - 可能是JUnit测试运行器

  1. PIT picking up tests not included/are excluded in the normal test config
  2. Tests rely on an environment variable or other property set in the test config, but not set in the pitest config
  3. Tests have a hidden order dependency that is not revealed during the normal test run
  4. PIT doesn't like something in your tech stack - possibly a JUnit test runner

听起来你已经被淘汰了1& 2.留下3和4。

It sounds like you've eliminated 1 & 2. so that leaves 3 and 4.

测试订单依赖关系很难发现。如果答案是肯定的,那么你可能有一个。

Test order dependencies can be hard to spot. If the answer is yes to any of these you may have one.


  • 你的代码库是否包含可变的静态状态? (例如,在单身人士中)

  • 您的测试是否在数据库(内存或其他方面)中,测试之间状态是否可以持续?

  • 您的测试会修改磁盘上的文件吗?

上面可能还有很多其他原因。

There are probably also many other causes not listed above.

如果您确信代码库中的订单依赖性是不可能的,那么这些特定测试就会出现问题。

If you are confident that order dependencies are impossible in your code base, that leaves a problem with these particular tests.

很难猜到是什么这可能没有一些代码。您是否可以发布仍然失败的测试的简化版本?

It's hard to guess what this might be without some code. Can you post a simplified version of the test that still fails?

这篇关于JUnit测试通过,但PIT称该套件不是绿色的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆