Native Integration Unavailable Exception for ProjectBuilder

Dear Gradle experts,

I tried to test my custom plugin on Java:

@Test(groups = “upload”)
public void testUploadGradlePlugin() {

    Project project = ProjectBuilder.builder().build();
    project.getPluginManager().apply(TestIQPlugin.class);  //TestIQPlugin is the custom plugin class name
    UploadTask uploadTask = project.getTasks().create("testiqUploadTaskTest", UploadTask.class); 
uploadTask.processUpload();
}

It compiles fine but runtime hit exception:

Exception in thread “main” java.lang.NoClassDefFoundError: net/rubygrapefruit/platform/NativeIntegrationUnavailableException
at org.gradle.testfixtures.internal.ProjectBuilderImpl.createProject(ProjectBuilderImpl.java:74)
at org.gradle.testfixtures.ProjectBuilder.build(ProjectBuilder.java:99)

By the way, I executed the code from Java’s main method. I appreciate any kind of help.

Well, testing doesn’t work like that. The error you get is because you miss some dependencies, used by Gradle.
One of the easiest way to test your plug-in is to use the gradle test kit

Thanks a lot for the advice!