private static void clearTemporaryFolder(Path temporaryFolder){
        try (Stream<Path> paths = Files.walk(temporaryFolder)) {
            paths.sorted((a, b) -> b.getNameCount() - a.getNameCount())
                    .forEach(path -> {
                        try {
                            Files.delete(path);
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                    });
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
Boots up the application on a separate thread (blocks this thread) and then does the following:
- Takes screenshots on the requested frames
- After all the frames have been taken it stops the application
- Compares the screenshot to the expected screenshot (if any). Fails the test if they are different
jme3-screenshot-tests/src/main/java/org/jmonkeyengine/screenshottests/testframework/TestDriver.java