I have to write a program that run JUnit test case from a user interface.
I found that I can use JUnitCore
class to run tests with method:
junit.run(class files);
but this requires the .class file containing the tests. I need to obtain the .class files having only a path of a directory that contains the JUnit .java files but I don't know how to get reference to these and use them with the run() method. Any suggestion? Thanks in advance
EDIT
As it has been pointed out I don't need the .class files but an instance of Class for every java file in the directory. How can I get it?
EDIT 2
Just solved with parsing the path of file and using the Class.forname(String)
method!