为什么Pit无法为我的生产课上我的测试课?

发布于 2025-01-26 18:17:34 字数 946 浏览 1 评论 0原文

我正在尝试制作 pit 运行一个基于春季/Maven的Java项目,但获得了奇怪的结果。我的第一个运行显示了各种突变的timed_out s的压倒性数量。 其FAQ中的一般建议,例如增加超时设置,并没有产生任何改进。

因此,我选择了一个示例来分析发生的事情:stringutilities是一个普通类,具有一些static执行简单字符串操作的方法,例如修剪空格等。我输入<<<代码>&lt; targetClasses&gt;&lt param&gt; **。弦乐量&lt;/param&gt;&gt;/targetClasses&gt; 单独集中此类。

令人惊讶的观察结果是,Pit的报告在运行的“测试”部分中列出了数十类。但是,最重要的是,stringutiltestiest是专门为此现场类编写的单元测试类,是 not 。要验证,我将其输入为&lt; targetTests&gt;&gt; param&gt; **。 0%突变覆盖率。

显而易见的事情是检查班级路径,但我看不到任何奇怪的事情。前面的Maven构建可以选择测试课程。该项目使用标准的主/测试文件夹结构,该类位于Live Package的测试镜中。

我注意到的一件事是,我的测试套件包括Junit 4和Junit 5测试的组合。该项目正在迁移到较新的版本,但在几周或几个月的时间内逐步迁移。 Stringutilitiest是Junit 5。

坑有这种版本混合物是否有问题?还有其他可能的解释,为什么未上测试类?

I am trying to make PIT run for a Spring/Maven-based Java project, but get strange results. My first runs show an overwhelming number of TIMED_OUTs for all sorts of mutations. The general recommendations in their FAQ, such as increasing the timeout settings, didn't yield any improvements.

So I picked out one sample to analyze what's happening: StringUtilities is a plain class with some static methods that perform simple string manipulations, such as trimming whitespace, etc. I entered <targetClasses><param>**.StringUtilities</param></targetClasses> to focus this class alone.

The surprising observation was that PIT's report listed tens of test classes in the "Tests examined" section that it ran. However, the most important one, StringUtiltiesTest, the unit test class that was specifically written for this live class, was not included. To verify, I entered it as <targetTests><param>**.StringUtilitiesTest</param></targetTests>, and indeed, PIT said it couldn't find any test and calculated 0% mutation coverage.

The obvious thing to do was checking the class path, but I cannot see anything strange about it. The preceeding Maven build picks the test class up alright. The project uses a standard main/test folder structure, and the class is located in the live package's test mirror.

One thing I did notice was that my test suite consists of a mix of JUnit 4 and JUnit 5 tests. The project is migrating to the newer version, but piece by piece, over a course of several weeks or months. StringUtilitiesTest is JUnit 5.

Does PIT have problems with such a version mixture? Are there other possible explanations why the test class isn't picked up?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文