I would like to test to see if a variable exists in JUnit testing.
I have a class called animal which is an abstract class.
public abstract class Animal {
private final int age;
private final int speed;
public Animal (int age,int speed) {
this.age = age;
this.speed = speed;
}
public static void main(String[] args) {
}
@Override
public boolean equals(Object anotherObject) {
if (this == anotherObject) {
return true;
}else {
return false;
}
}
public abstract Animal[] multiply(int n);
private boolean isFaster(Animal a) {
if(this.getSpeed() >a.getSpeed()) {
return true;
}else {
return false;
}
}
private boolean isOlder(Animal a) {
if(this.getAge() >a.getAge()) {
return true;
}
return false;
}
@Override
public String toString() {
return this.getClass()+ "is " + this.getAge() + " years old, is " +this.getSpeed() +" units fast.";
}
public final int getAge() {
return age;
}
public final int getSpeed() {
return speed;
}
}
I would like to test to see if the variable age exists and also if it is private and final. How would I potentially do this in Junit testing?
Aucun commentaire:
Enregistrer un commentaire