private static Result invokeRun(final String className, final ClassLoader cl) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, IOException, InvocationTargetException { TestExecutionContext.current().ifPresent(ctx -> { System.getProperties().putAll(ctx.getEnv()); init(ctx, cl); }); try { final Class<?> testClass = cl.loadClass(className); final Object runner = cl.loadClass(JUnitRunner.class.getName()).newInstance(); final Method run = runner.getClass().getDeclaredMethod("run", Class.class); return new ResultHelper().deserialize((byte[]) run.invoke(runner, testClass)); } finally { TestExecutionContext.current().ifPresent(ctx -> destroy(ctx, cl)); } }