### Question:
MainMethodRunner { public Object run() throws Exception { Class<?> mainClass = Thread.currentThread().getContextClassLoader() .loadClass(this.mainClassName); Method mainMethod = mainClass.getDeclaredMethod("main", String[].class); return mainMethod.invoke(null, new Object[] { this.args }); } MainMethodRunner(String mainClass, String[] args); Object run();  }### Answer:
@Test public void testRunner() { MainMethodRunner mainMethodRunner = new MainMethodRunner(MainClass.class.getName(), new String[] { "10" }); try { mainMethodRunner.run(); Assert.assertTrue(MainMethodRunnerTest.count == 10); } catch (Exception e) { Assert.assertNull(e); } }