mardi 9 juin 2015

Get full path of a package situated in source folder from junit

I have used below code in my junit to get the directory of my package.

String pkgname = "com.acn.omi.util";
String relPath = pkgname.replace('.', '/');
URL resource = ClassLoader.getSystemClassLoader().getResource(relPath);

But this code search for package in target/test-classes folder which contain classes from src/test/java source folder so it is not able to find the package situated in my source folder(src/main/java).

How can i get the file situated in a package from junit.

My purpose is to load all the classes from that folder and modify their field using reflection.





Aucun commentaire:

Enregistrer un commentaire