Let me explain the use case first.
The use case is that a learner learning java
is following a set of written instructions and using automated tests (read JUnit
), I want to test whether they have successfully implemented the instruction.
Things that I need to find out programmatically, for example, is if a for
loop exists in the code. Consider the following code
class AClass {
public static void main(String[] args){
for(int i=1; i<11; i++){
System.out.println("Count is: " + i);
}
}
}
Is there a way that using reflection API, I can assert that AClass
contains for(int i=1; i<11; i++)
? Or any other way?
This question is an example. Ideally, there could be a code such as if (x) {}
that I may want to find out inside a class.
I am not sure how feasible this is.
Thank you
Aucun commentaire:
Enregistrer un commentaire