【发布时间】:2015-12-31 18:06:32
【问题描述】:
我正在使用 µ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:孩子
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;
}
}
但是当我运行 Mutation Testing 时,我发现突变体还活着。我想杀了它! 我该怎么办??
【问题讨论】:
-
不知道 µJava 是什么,我在您提供的代码中看不到任何不是普通 Java 的东西。作为旁注:
c1也是Parent类型,因为Child是Parent的子类
标签: java unit-testing mutation mutation-testing