コード例 #1
0
  @Test
  public void reportsTyposInTaskName() {
    final Task task1 = task("someTask");
    final Task task2 = task("someTasks");
    final Task task3 = task("sometask");
    final Task task4 = task("other");

    context.checking(
        new Expectations() {
          {
            one(project).getTasksByName("ssomeTask", true);
            will(returnValue(toSet()));
            one(taskContainer).getAll();
            will(returnValue(toSet(task1, task2)));
            one(subProjectTaskContainer).getAll();
            will(returnValue(toSet(task3, task4)));
          }
        });

    TaskNameResolvingBuildExecuter executer =
        new TaskNameResolvingBuildExecuter(toList("ssomeTask"));
    try {
      executer.select(gradle);
      fail();
    } catch (TaskSelectionException e) {
      assertThat(
          e.getMessage(),
          equalTo(
              "Task 'ssomeTask' not found in [project]. Some candidates are: 'someTask', 'someTasks', 'sometask'."));
    }
  }
コード例 #2
0
  @Test
  public void failsWhenUnknownTaskNameIsProvided() {
    final Task task1 = task("t1");
    final Task task2 = task("t2");

    context.checking(
        new Expectations() {
          {
            one(project).getTasksByName("b3", true);
            will(returnValue(toSet()));
            one(taskContainer).getAll();
            will(returnValue(toSet(task1, task2)));
            one(subProjectTaskContainer).getAll();
            will(returnValue(toSet()));
          }
        });

    BuildExecuter executer = new TaskNameResolvingBuildExecuter(toList("b3"));
    try {
      executer.select(gradle);
      fail();
    } catch (TaskSelectionException e) {
      assertThat(e.getMessage(), equalTo("Task 'b3' not found in [project]."));
    }
  }
コード例 #3
0
  @Test
  public void failsWhenProvidedNameIsAmbiguous() {
    final Task task1 = task("someTask");
    final Task task2 = task("someTasks");

    context.checking(
        new Expectations() {
          {
            one(project).getTasksByName("soTa", true);
            will(returnValue(toSet()));
            one(taskContainer).getAll();
            will(returnValue(toSet(task1)));
            one(subProjectTaskContainer).getAll();
            will(returnValue(toSet(task2)));
          }
        });

    TaskNameResolvingBuildExecuter executer = new TaskNameResolvingBuildExecuter(toList("soTa"));
    try {
      executer.select(gradle);
      fail();
    } catch (TaskSelectionException e) {
      assertThat(
          e.getMessage(),
          equalTo(
              "Task 'soTa' is ambiguous in [project]. Candidates are: 'someTask', 'someTasks'."));
    }
  }
コード例 #4
0
  @Test
  public void failsWhenUnknownTaskPathIsProvided() {
    context.checking(
        new Expectations() {
          {
            one(project).findProject("a");
            will(returnValue(null));
          }
        });

    BuildExecuter executer = new TaskNameResolvingBuildExecuter(toList("a:b", "name2"));
    try {
      executer.select(gradle);
      fail();
    } catch (TaskSelectionException e) {
      assertThat(e.getMessage(), equalTo("Project 'a' not found in [project]."));
    }
  }