- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用μJava对我的java程序进行突变测试。因为我正在学习突变测试。
我有两个类
1:父级
public class Parent
{
public String temp;
public int number;
public Parent(String temp)
{
this.temp = temp;
this.number = 20;
}
public String printTemp()
{
return "temp is : "+temp+number;
}
}
和2: child
public class Child extends Parent
{
public int number;
public Child(String temp)
{
super(temp);
this.number = 5;
}
public String printTemp()
{
String temp = "i am fake !";
int number = 766;
return "temp is : "+super.temp+this.number+"c";
}
}
我正在应用muJava的IOD操作。 `因此它正在产生突变体。它正在删除子类的重写方法 printTemp。
我的测试用例是:
public class MyTest
{
public String test1 ()
{
String result;
Parent p1 = new Parent("i am temp of parent");
Child c1 = new Child("i am temp of child");
Parent p2 = new Child("i am both !");
result = ""+ c1.printTemp() + p1.printTemp() + p2.printTemp();
return result;
}
}
但是当我进行突变测试时,我发现突变体还活着。我想杀了它!我能做什么??
最佳答案
MuJava 已将其测试基础架构切换到 JUnit(请参阅 https://cs.gmu.edu/~offutt/mujava/,第 III.3 节)。这意味着您应该编写一个 JUnit 测试,它不仅涵盖代码,还对结果进行断言。
示例:
@Test
public void testPrintTempChild() {
Child c = new Child("Child");
String actual = c.printTemp();
String expected = "temp is : Child5c";
assertEquals(expected, actual);
}
@Test
public void testPrintTempParent() {
Parent p = new Parent("Parent");
String actual = p.printTemp();
String expected = "temp is : Parent20";
assertEquals(expected, actual);
}
如果应用 IOD 突变运算符,第一个测试应该检测到该突变体(即,它应该失败,因为 printTemp 返回“temp is : Child20”)。
作为附加注释,测试代码中的引用 p2 也是 Child 的实例,因此 c1.printTemp() 和 p2.printTemp() 都会调用 Child 类中的 printTemp 方法。
关于java - µJava不是在杀变种人吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32925644/
我正在尝试使用宽度数组以特定宽度打印变量。我想做类似的事情 int widthArr[] = {5, 4}; uint32_t var1 = 123; uint32_t var2 = 4567; pr
我正在尝试创建一个脚本来启动另一个脚本并将其直接作为子脚本。我的目标是: 子程序应该看到一个不同的 $HOME 子脚本应该在与当前工作目录不同的目录中运行(即不同的密码) 没有多余的壳 我通过子 sh
我只是尝试通过 PATH env 解析其位置来运行一个新进程。变种。因为我使用 Qt 这意味着我添加了 X:\文件夹\ 到我的 PATH 变量和我正在调用的启动应用程序中 QProcess::star
我是一名优秀的程序员,十分优秀!