如何对我的 Java 程序执行突变测试?

发布于 2024-11-17 09:53:36 字数 92 浏览 11 评论 0原文

任何人都可以提供可用于在源代码(而非字节代码)级别在 Java 程序中进行突变的工具建议吗?我需要在我的源代码中添加错误。我更喜欢带有 GUI 的应用程序(如果有的话)。

Can anyone provide suggestions of tools that can be used to make mutations within a Java program at a source-code (not byte-code) level? I need to seed my source code with faults. I would prefer an application with a GUI, if one exists.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

2024-11-24 09:53:37

如果您的要求确实是源代码突变,那么我知道的选项是

Jester - 提供有限数量的非常不稳定的突变运算符。 Jeff Offutt 将其描述为应用分支测试的一种非常昂贵的方法。不过,我相信可以定义自己的运算符,因此这可能不完全公平。

Mu Java - 不支持 Java 5

Judy - 除了它存在之外对此不太了解

Lava - 听起来很基本,我认为它不支持 java 5

从下面的答案中我看到你现在使用 PIT。我认为这确实是一个很好的选择(我写的所以可能有一定的偏见),但它是一个字节码突变系统。

If your requirement really is for source code mutation then the options I'm aware of are

Jester - Provides a limited number of mutation operators that are quite unstable. Jeff Offutt described it as a very expensive way to apply branch testing. I believe it is possible to define your own operators however, so this probably isn't entirely fair.

Mu Java - Doesn't support Java 5

Judy - Don't know much about this other than that it exists

Lava - Sounds pretty basic and I don't think it supports java 5

From the answer further down I see your now using PIT. I think that's a truly great choice (I wrote it so may have a certain bias), but it's a byte code mutation system.

太傻旳人生 2024-11-24 09:53:37

我发现了 https://pitest.org,我非常喜欢。对于 MuJava,我遇到了由 @Override 注释引起的异常。似乎不支持 Java 5/6。

I've found https://pitest.org, which I quite like. With MuJava I have exceptions caused by @Override annotations. Seems that it doesnt' support Java 5/6.

我喜欢麦丽素 2024-11-24 09:53:37

当我在 GMU 参加软件工程测试课程时,我们使用 Mu Java,其中一章。华泰

When I took a software engineering class on testing at GMU, we used Mu Java, for one of the chapters. HTH

绅士风度i 2024-11-24 09:53:37

这是开源测试覆盖工具 Jester 使用的技术。如果您无法找到合适的工具并想自己构建一个,那么查看它的源代码可能会有所帮助。

This is the technique used by the open source test coverage tool Jester. A look at it's source might be helpful if you are unable to find a suitable tool and want to build one yourself.

秋千易 2024-11-24 09:53:37

“这在现实世界中几乎没有应用”。强烈不同意,我与英国一家非常大的媒体公司和 PIT (http://pitest.org/ )对于突变测试非常有用。如果没有 85% 覆盖率的 PIT 突变测试,大多数 CI 构建都会失败。
回复:“替换一些随机字符......”突变不一定是这个意思。 PIT 突变仅限于可编译的更改。

"This has little application in the real world". Disagree strongly, I contract at a very big media company in the UK and PIT (http://pitest.org/) is extremely useful for mutation testing. Most of the CI builds are set fail without 85% coverage PIT mutation testing.
Re: "replacing some random characters..." Mutation does not have to mean that. The PIT mutations are restricted to compilable changes.

潦草背影 2024-11-24 09:53:37

这是一个基准:

MμClipse 仅支持 JUnit 3 并且不再维护。
而Jester则比较费力并且需要复杂的配置; plus 不再维护。
我能找到的最好的工具是 Javalanche
我写了整篇关于此的文章!< /a>

Here it is a benchmark :

MμClipse only supports JUnit 3 and is no longer maintained.
Jester as for it, is laborious and requires a complicated configuration; plus is not maintained anymore.
The best tool I could find is Javalanche
I had wrote a entire article about this !

飘然心甜 2024-11-24 09:53:37

Major 变异框架(Major 网站)为 JUnit 测试提供了编译器集成的变异器和变异分析器。

Major 的变异器集成在 Java 7 编译器中。它提供了多个突变运算符,并支持两种用于突变源代码的选项:

  1. 在编译期间生成并嵌入所有突变体
  2. 生成突变体并导出突变源文件

The Major mutation framework (Major's website) provides a compiler-integrated mutator and a mutation analyzer for JUnit tests.

Major's mutator is integrated in the Java 7 compiler. It provides several mutation operators and supports two options for mutating source code:

  1. Generate and embed all mutants during compilation
  2. Generate mutants and export mutated source files
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文