Software Testing Mutation Operators Example Codes (SKD)Super Keyword Deletion
class A{
int a;
void show(){
System.out.println(a);
}
}
class B extends A{
int a;
void setA(int a_){
super. a = a_; // If we delete the super keyword
}
}
public class Main{
public static void main(String[] args) {
B ob = new B();
ob.setA(10);------>Acessed from parent class A , hence the output is 0 instead of 10
ob.show();
}
}
Mutation Testing is a method to evaluate the quality of software tests. A mutation operator introduces small changes (mutations) in the code to check if the existing tests can catch the errors.
The Super Keyword Deletion (SKD) operator removes the super keyword, which refers to a member of the parent class from the child class
Class A has an integer variable a and a method show() that prints it.
No comments:
Post a Comment