mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
[examples] Add unit testing infrastructure (#4646)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user