How to run build scripts while testing a Gradle plugin?

I am writing a Gradle plugin, and I want to test it against some of my build. gradle files. How can I do this?

In other words I am looking for the Gradle equivalent of this Maven script:

public void testSomething() throws Exception

{

File pom = getTestFile( “src/test/resources/unit/project-to-test/pom.xml” );

assertTrue( pom.exists() );

MyMojo myMojo = (MyMojo) lookupMojo( pom );

myMojo.execute();

}

You can use the Tooling API for this.