public static void main(String[] args) { if (args.length < 1) { System.out.println("Please give the configuration file name as first argument"); return; } Map<String, Long> executionTimes = new HashMap<String, Long>(); InputSource inputSource = new InputSource(args[0]); List<Test> tests = getTests(inputSource); if (tests == null) return; Emailer emailer = parseEmailer(inputSource); if (emailer == null) return; List<List<String>> outputs = new ArrayList<List<String>>(); for (Test test : tests) { try { System.out.println("Running test " + test.getName()); long startTime = System.currentTimeMillis(); BufferedReader bufferedReader = null; for (int i = 0; i < test.getNRuns(); i++) { Process process = Runtime.getRuntime().exec(test.getCommand()); if (test.getOutput().equals("console")) { bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); } else { bufferedReader = new BufferedReader(new FileReader(test.getOutput())); } process.waitFor(); } executionTimes.put(test.getName(), System.currentTimeMillis() - startTime); outputs.add(getLines(bufferedReader)); System.out.println("Test " + test.getName() + " executed"); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } String message = ""; int size = tests.size(); for (int i = 0; i < size; i++) { for (int j = 0; j < i; j++) { String differences = Diff.diff(outputs.get(i), outputs.get(j)); if (!differences.isEmpty()) { message += "Differences between " + tests.get(j).getName() + " and " + tests.get(i).getName() + " tests\n"; message += differences; } } } System.out.println("Sending e-mails"); if (!message.isEmpty()) { message = "Some tests failed:\n" + message; } else { message = "Tests run successfully\n"; } message += "Time of execution:\n"; for (String name : executionTimes.keySet()) { message += name + " : " + executionTimes.get(name) + "ms\n"; } emailer.send(message); System.out.println("E-mails sent"); }