After re-organizing my Python code I have moved on to Java JUnit tests. I remember using this in school but unfortunately I forgot and had to look it up again. Steps are relatively straight-foward.
1. In the package, add a new class, at the top of the file: import org.junit.Test; import static org.junit.Assert.*;
2. If the imports above don't resolve, go to the package explorer -> right click on project -> Build Path -> Configure Build Path -> Libaries Tab -> Add Library -> Select JUnit (should already be in the list with JRE System Library, Maven Managed Dependencies and User Libary -> Next -> Finish
3. Inside the class add tests with @Test Java annotation, use assertTrue/False/Null/NotNull/Equals/ArrayEquals etc to define the expected behaviour
4. To test exceptions add @Test(expected = <Exception Class Name>.class) to the space above the function declaration. Note we don't need to assert anything unlike the other cases
E.g. @Test(expected = IllegalArgumentException.class)
public void MyTest() {
my_function(a, b);
}
5. When running the test, the IDE will usually let you choose between JUnit test and regular Java Application. Select JUnit test.
6. The results will show the stats and if the tests failed there is a stack that can show which line was the failed test etc.