I am trying to make some JUnit tests for my code. But the problem is, I make use of the Java Models like ICompilationUnit, IPackageFragment, ITypes and etc. I did not get how to create some ICompilationUnit and then test. I searched google and stackoverflow for information but did not find something.
My question is, how can I make Junit test with classes of the jdt.core...can somebody give me may be some code examples.
Thanks
Here is a Method I coded:
private void updateLists() {
if(!getCompilationUnit().isEmpty()){
for(int i = 0; i < getCompilationUnit().size(); i++){
try {
Document doc = new Document(getCompilationUnit().get(i).getSource());
int totalNumberOfCode = doc.getNumberOfLines();
IType type = getCompilationUnit().get(i).findPrimaryType();
IType[] types = getCompilationUnit().get(i).getTypes();
updateListPrimaryType(type, totalNumberOfCode, types);
updateListIMethod(type);
updateListMember(type,types);
} catch (JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}