GroovyScriptEngine implements ScriptEngine { @Override public ScriptEngineService.WorkerRunnable createWorkerRunnable() throws EngineException { try { return new GroovyWorkerRunnable(new GrinderContextExecutor(m_groovyClass)); } catch (InitializationError e) { throw new EngineException("Exception occurred during initializing runner", exceptionProcessor.sanitize(e)); } } GroovyScriptEngine(ScriptLocation script); @Override ScriptEngineService.WorkerRunnable createWorkerRunnable(); @Override ScriptEngineService.WorkerRunnable createWorkerRunnable(Object testRunner); @Override void shutdown(); @Override String getDescription();  }
@Test public void testRunGroovyScript() throws EngineException, NoSuchFieldException, IllegalAccessException { JUnitThreadContextInitializer init = new JUnitThreadContextInitializer(); init.initialize(); String file = getClass().getClassLoader().getResource("org/ngrinder/TestRunner.groovy").getFile(); GroovyScriptEngine engine = new GroovyScriptEngine(new ScriptLocation(new File(file).getAbsoluteFile())); init.attachWorkerThreadContext(); GroovyScriptEngine.GroovyWorkerRunnable worker = (GroovyScriptEngine.GroovyWorkerRunnable) engine .createWorkerRunnable(); assertStaticField(engine.m_groovyClass, "callCount1", 0); assertStaticField(engine.m_groovyClass, "callCount2", 0); worker.run(); assertStaticField(engine.m_groovyClass, "callCount1", 1); assertStaticField(engine.m_groovyClass, "callCount2", 1); worker.run(); assertStaticField(engine.m_groovyClass, "callCount1", 2); assertStaticField(engine.m_groovyClass, "callCount2", 2); }