dependencies {
    testImplementation testLibs.junit.jupiter.api
    testImplementation testLibs.junit.jupiter.params
    testImplementation testLibs.hamcrest
    testRuntimeOnly testLibs.junit.jupiter.engine
    testRuntimeOnly testLibs.junit.jupiter.platform.launcher
}

test {
    useJUnitPlatform()
    failFast = false
    jvmArgs '--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED',
            '--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED',
            '--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
            '--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
            '--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED',
            '--add-opens=java.base/java.lang=ALL-UNNAMED',
            '--add-opens=java.base/java.lang.reflect=ALL-UNNAMED',
            '--add-opens=java.base/java.io=ALL-UNNAMED',
            '--add-opens=java.base/java.nio=ALL-UNNAMED',
            '--add-opens=java.base/java.util=ALL-UNNAMED',
            '--add-opens=java.base/sun.security.util=ALL-UNNAMED'
    systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
    environment 'NOTIFY_SOCKET', '/run/systemd/notify'
    environment 'JOURNAL_SOCKET', '/run/systemd/journal/socket'
    testLogging {
        events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED'
        showStandardStreams = true
    }
    afterSuite { desc, result ->
        if (!desc.parent) {
            println "\nTest result: ${result.resultType}"
            println "Test summary: ${result.testCount} tests, " +
                    "${result.successfulTestCount} succeeded, " +
                    "${result.failedTestCount} failed, " +
                    "${result.skippedTestCount} skipped"
        }
    }
}
