[examples] Add unit testing infrastructure (#4646)

This commit is contained in:
Starlight220
2022-12-02 18:40:14 +02:00
committed by GitHub
parent 74cc86c4c5
commit 66bb0ffb2c
15 changed files with 444 additions and 13 deletions

View File

@@ -174,8 +174,9 @@ model {
new groovy.json.JsonSlurper().parseText(exampleFile.text).each { entry ->
project.tasks.create("run${entry.foldername}", JavaExec) { run ->
mainClass = "edu.wpi.first.wpilibj.examples." + entry.foldername + ".Main"
classpath = sourceSets.main.runtimeClasspath
run.group "run examples"
run.mainClass = "edu.wpi.first.wpilibj.examples." + entry.foldername + "." + entry.mainclass
run.classpath = sourceSets.main.runtimeClasspath
run.dependsOn it.tasks.install
run.systemProperty 'java.library.path', filePath
run.environment 'LD_LIBRARY_PATH', filePath
@@ -186,6 +187,23 @@ model {
run.jvmArgs = ['-XstartOnFirstThread']
}
}
project.tasks.create("test${entry.foldername}", Test) { testTask ->
testTask.group "verification"
testTask.useJUnitPlatform()
testTask.filter {
includeTestsMatching("edu.wpi.first.wpilibj.examples.${entry.foldername}.*")
setFailOnNoMatchingTests(false)
}
testTask.classpath = sourceSets.test.runtimeClasspath
testTask.systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
testTask.testLogging {
events "failed"
exceptionFormat "full"
}
testTask.systemProperty 'java.library.path', filePath
testTask.environment 'LD_LIBRARY_PATH', filePath
testTask.workingDir filePath
}
}
found = true