How can I unit test the TaskExecutionGraph?


(Matt Khan) #1

I’m writing some plugins that are intended to wire up a multi project build in some specific way so that you basically get

rootproject task 1 -> a bunch of child project tasks -> root project task 2

I would like to be able to unit test the ordering of the tasks within the task execution graph but I can’t see how to force the evaluation of a Project (constructed via ProjectBuilder). I can see some of the things involved but not how to access them outside of running gradle. Is this possible?


(Rolf Suurd) #2

You can obtain a tasks’s dependencies, and check if it depends on the expected tasks:

task.taskDependencies.getDependencies(task)*.name.contains(MyTask.TASK_NAME)

This may not be exactly what you are looking for, since requires you to know what the “last” task in the chain is, and look “back” in the graph, but with some effort you can check the entire task chain for a single task.

Greets Rolf