### Question:
CarrotGroovyRunner { public Object execute(final File script) throws Exception { final GroovyShell shell = new GroovyShell(binding()); final Object result = shell.evaluate(script); return result; } CarrotGroovyRunner(final MavenProject project); Binding binding(); Object execute(final File script); Object execute(final String script);  }### Answer:
@Test public void testFile() throws Exception { final Properties properties = new Properties(); properties.put("prop-key", "prop-value-1"); assertEquals(properties.get("prop-key"), "prop-value-1"); final MavenProject project = mock(MavenProject.class); when(project.getProperties()).thenReturn(properties); final CarrotGroovyRunner runner = new CarrotGroovyRunner(project); final File script = new File("./src/test/resources/script.groovy"); final Object result = runner.execute(script); assertEquals(result, "result"); assertEquals(properties.get("prop-key"), "prop-value-2"); }
@Test public void testString() throws Exception { final Properties properties = new Properties(); properties.put("prop-key", "prop-value-1"); assertEquals(properties.get("prop-key"), "prop-value-1"); final MavenProject project = mock(MavenProject.class); when(project.getProperties()).thenReturn(properties); final CarrotGroovyRunner runner = new CarrotGroovyRunner(project); final File file = new File("./src/test/resources/script.groovy"); final String script = FileUtils.readFileToString(file); final Object result = runner.execute(script); assertEquals(result, "result"); assertEquals(properties.get("prop-key"), "prop-value-2"); }