犬.java
public class Dog extends Animal {
.....
}
Animal.java
public class Animal {
public static String getName() {
String callerClassName = ????; //How to get the class Dog, when I call from TestCase
return "Animal";
}
}
TestCase クラスを Dog.getName() に使用する場合、Thread.currentThread().getStackTrace()[1].getClassName() を使用するときに Animal ではなく Dog という className を取得する方法
public class TestCase {
public static String getName(){
return Dog.getName();
}
}