You can open this sample inside an IDE using the IntelliJ native importer or Eclipse Buildship.

This sample shows how to test a Java Native Interface (JNI) library with JUnit. The library has a single dependency on the JUnit, and the build has a minimal configuration.

In this sample, we are testing a JNI library implemented in Java and C++ with JUnit4; however, this applies to other JVM and native languages as well.

build.gradle
plugins {
	id 'java'
	id 'dev.nokee.jni-library'
	id 'dev.nokee.cpp-language'
}

repositories {
	mavenCentral()
}

dependencies {
	testImplementation 'junit:junit:4.12'
}
build.gradle.kts
plugins {
	id("java")
	id("dev.nokee.jni-library")
	id("dev.nokee.cpp-language")
}

repositories {
	mavenCentral()
}

dependencies {
	testImplementation("junit:junit:4.12")
}

To test the library:

$ ./gradlew test

BUILD SUCCESSFUL
5 actionable tasks: 5 executed

The test result are produced inside ./build/reports/tests/:

$ ls ./build/reports/tests/test/index.html
./build/reports/tests/test/index.html

For more information, see JNI Library Plugin reference chapter.