TaskRunner { public static void main(String[] args) { if (args.length < 1) { System.err.println("Name of the class to run is expected."); System.exit(EX_USAGE.getCode()); } String className = args[0]; Class<?> clazz = getClass(className); Task task = createTask(clazz); String[] taskArgs = createTaskArgs(args); int exitValue = task.doMain(taskArgs); if (exitValue != 0) { System.exit(exitValue); } }  static void main(String[] args);  }
@Test(expected = DummyException.class) public void testLoadClass() { TaskRunner.main(new String[] { DummyTask.class.getName() }); }
@Test public void testLoadClassNoClass() { exit.expectSystemExitWithStatus(EX_USAGE.getCode()); TaskRunner.main(new String[0]); }
@Test public void testLoadClassFail() { exit.expectSystemExitWithStatus(EX_USAGE.getCode()); TaskRunner.main(new String[] { "does.not.exists.Class" }); }
@Test public void testLoadClassFailOnPrivate() { exit.expectSystemExitWithStatus(EX_USAGE.getCode()); TaskRunner.main(new String[] { PrivateDummyTask.class.getName() }); }
@Test public void testLoadClassPassedArgsToDoMain0() { TaskRunner.main(new String[] { DummyTaskArgs0.class.getName() }); }
@Test public void testLoadClassPassedArgsToDoMain1() { TaskRunner.main(new String[] { DummyTaskArgs1.class.getName(), ARG0 }); }