### Question:
ClojureScriptEngine implements ScriptEngine { @Override public WorkerRunnable createWorkerRunnable() throws EngineException { final Object result; try { result = m_runnerFactory.call(); } catch (final Exception e) { throw new ClojureScriptExecutionException( "Failed to create test runner function", e); } if (!(result instanceof Callable<?>)) { throw new ClojureScriptExecutionException( "The script should return a function that creates a test runner " + "function " + "[It returned " + describeResult(result) + "]"); } return new ClojureWorkerRunnable((Callable<?>) result); } ClojureScriptEngine(final ScriptLocation script); @Override WorkerRunnable createWorkerRunnable(); @Override WorkerRunnable createWorkerRunnable(final Object testRunner); @Override String getDescription(); @Override void shutdown();  }### Answer:
@Test public void testNoWorkerRunnable() throws Exception { final ScriptLocation script = new ScriptLocation(new Directory(getDirectory()), new File("my.clj")); createFile(script.getFile(), "(fn [] ())"); final ScriptEngine scriptEngine = new ClojureScriptEngineService().createScriptEngine(script); try { scriptEngine.createWorkerRunnable(); fail("Expected ScriptExecutionException"); } catch (final ScriptExecutionException e) { assertContains(e.getMessage(), "should return a function"); } }
@Test public void testNilWorkerRunnable() throws Exception { final ScriptLocation script = new ScriptLocation(new Directory(getDirectory()), new File("my.clj")); createFile(script.getFile(), "(fn [] nil)"); final ScriptEngine scriptEngine = new ClojureScriptEngineService().createScriptEngine(script); try { scriptEngine.createWorkerRunnable(); fail("Expected ScriptExecutionException"); } catch (final ScriptExecutionException e) { assertContains(e.getMessage(), "should return a function"); } }
@Test public void testBadRunnerFactory() throws Exception { final ScriptLocation script = new ScriptLocation(new Directory(getDirectory()), new File("my.clj")); createFile(script.getFile(), "(fn [] (throw))"); final ScriptEngine scriptEngine = new ClojureScriptEngineService().createScriptEngine(script); try { scriptEngine.createWorkerRunnable(); fail("Expected ScriptExecutionException"); } catch (final ScriptExecutionException e) { assertTrue(e.getCause() instanceof NullPointerException); } }
@Test public void testCreateWorkerRunnableWithBadRunner() throws Exception { final ScriptLocation script = new ScriptLocation(new Directory(getDirectory()), new File("my.clj")); createFile(script.getFile(), "(fn [] ())"); final ScriptEngine scriptEngine = new ClojureScriptEngineService().createScriptEngine(script); try { scriptEngine.createWorkerRunnable(this); fail("Expected ScriptExecutionException"); } catch (final ScriptExecutionException e) { assertContains(e.getShortMessage(), "testRunner is not a function"); } }