@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].")); } }
@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].")); } }