Unittesting plugins that rely on projectsEvaluated

I am trying to write some unit tests for plugins that rely on lazy evaluation. For this they make use of the projectsEvaluated callback. Is there an easy way to test these lifecycle methods?

So far the best i’ve come up with is

project = ProjectBuilder.builder().build();
gradle = (DefaultGradle) project.getGradle();

But that feels hacky because it requires me to do a cast down to DefaultGradle. Is there some sort of test helper i can use for this ?

Another option is to use GradleLauncher to actual run the evaluation.

If you don’t want to do that, then what you have is the best that is available right now.