@Test
  public void skipsTaskWhoseOnlyIfPredicateIsFalse() {
    context.checking(
        new Expectations() {
          {
            allowing(task).getEnabled();
            will(returnValue(true));
            one(spec).isSatisfiedBy(task);
            will(returnValue(false));
            one(state).skipped("SKIPPED");
          }
        });

    executer.execute(task, state, executionContext);
  }
  @Test
  public void executesTask() {
    context.checking(
        new Expectations() {
          {
            allowing(task).getEnabled();
            will(returnValue(true));

            allowing(spec).isSatisfiedBy(task);
            will(returnValue(true));

            one(delegate).execute(task, state, executionContext);
          }
        });

    executer.execute(task, state, executionContext);
  }
  @Test
  public void wrapsOnlyIfPredicateFailure() {
    final Throwable failure = new RuntimeException();
    final Collector<Throwable> wrappedFailure = collector();
    context.checking(
        new Expectations() {
          {
            allowing(task).getEnabled();
            will(returnValue(true));
            one(spec).isSatisfiedBy(task);
            will(throwException(failure));
            one(state).executed(with(notNullValue(GradleException.class)));
            will(collectTo(wrappedFailure));
          }
        });

    executer.execute(task, state, executionContext);

    GradleException exception = (GradleException) wrappedFailure.get();
    assertThat(exception.getMessage(), equalTo("Could not evaluate onlyIf predicate for <task>."));
    assertThat(exception.getCause(), sameInstance(failure));
  }