void setUpMocksAndAttributes(GroovyCompile compile, final boolean groovyClasspathEmpty) {
    super.setUpMocksAndAttributes(compile);

    final FileCollection groovyClasspathCollection = context.mock(FileCollection.class);
    context.checking(
        new Expectations() {
          {
            allowing(groovyClasspathCollection).isEmpty();
            will(returnValue(groovyClasspathEmpty));
          }
        });

    compile.setGroovyClasspath(groovyClasspathCollection);
    compile.source(srcDir);
  }
  @Before
  public void setUp() {
    testObj = createTask(GroovyCompile.class);
    groovyCompilerMock = context.mock(Compiler.class);
    testObj.setCompiler(groovyCompilerMock);

    GFileUtils.touch(new File(srcDir, "incl/file.groovy"));
  }
 @Test
 public void testMoansIfGroovyClasspathIsEmpty() {
   setUpMocksAndAttributes(testObj, true);
   try {
     testObj.compile();
     fail();
   } catch (InvalidUserDataException e) {
     assertThat(e.getMessage(), containsString("'testTask.groovyClasspath' must not be empty."));
   }
 }
  public void testExecute(final int numFilesCompiled) {
    setUpMocksAndAttributes(testObj, false);
    context.checking(
        new Expectations() {
          {
            WorkResult result = context.mock(WorkResult.class);

            one(groovyCompilerMock)
                .execute((GroovyJavaJointCompileSpec) with(IsNull.notNullValue()));
            will(returnValue(result));
            allowing(result).getDidWork();
            will(returnValue(numFilesCompiled > 0));
          }
        });

    testObj.compile();
  }
 @Test
 public void testExecuteNotDoingWork() {
   testExecute(0);
   assertFalse(testObj.getDidWork());
 }
 @Test
 public void testExecuteDoingWork() {
   testExecute(7);
   assertTrue(testObj.getDidWork());
 }