I'm trying to automate a way to grade multiple students' files at once in my intro to Java class.
How can I run the same test(s) on all the files in a folder assuming the following conditions are true:
- All files exist in the same folder (no sub-folders)
- All files have a .java extension
- All filenames are important identifiers
- The code in every file meets the same requirements
SayHelloWorld
|-bsmithSayHelloWorld.java
|-athomasSayHelloWorld.java
|-cjenkinsSayHelloWorld.java
I'm comfortable with JUnit but I've only used it in a single-file, clunky way in the past through IntelliJ.
Here's a simple sample file I'd be testing against:
public class Main {
public static void main(String[] args) {
System.out.println(sayHello());
}
public static String sayHello(){
return "hello Java";
}
}
I would really like to be able to automate unit testing on all the .java files that exist in a given folder and output the results to something I can work with (console, file, whatever).
Possible output might look like:
bsmithSayHelloWorld helloWorldTest: pass
athomasSayHelloWorld helloWorldTest: fail
cjenkinsSayHelloWorld helloWorldTest: pass