Gradle plugin for running groups of tests with varied runtime requirements.
Features
- Easily define and run categories of tests
- Uses the standard
gradle test
task - IDE support for running tests in parallel
- Built-in allocation testing support for realtime safety
- Built on JUnit 5, Gradle, and JVM
- Load resources using file APIs with the
resource.dir
JVM property runningOnCIServer
boolean JVM property to improve running tests locally- Support for projects using ihmc-build plugin
- Generate empty test results when no tests are present to avoid false negative builds
- Provide list of tests and tags to be run in console output i.e. no uncertainty about which tests are run
- Set up full lifecycle logging for tests in --info log level i.e. started, passed, failed, skipped
Download
plugins {
id("us.ihmc.ihmc-build") version "0.15.5"
id("us.ihmc.ihmc-ci") version "3.4"
}
User Guide
This plugin defines a concept of categories
. Categories are communicated via the category
Gradle property (i.e. gradle test -Pcategory=fast
)and are used to set up a test process to run tests based on tags, parallel execution settings, and JVM arguments.
Built in categories
The default settings can be scaled via the cpuThreads
property (i.e. -PcpuThreads=8
). The default value is 8
.
Category | Configuration | Summary |
---|---|---|
fast | classesPerJVM = 0 // no limit maxJVMs = 2 maxParallelTests = 4 | Run untagged tests as fast as possible. Assume no special runtime requirements. |
allocation | classesPerJVM = 0 maxJVMs = 2 maxParallelTests = 1 includeTags += "allocation" jvmArgs += "allocationAgent" | Run only 1 test per JVM process so allocations don't overlap. Uses provided special accessor, allocationAgentJVMArg ,to get -javaagent:[..]java-allocation-instrumenter[..].jar |
Custom categories
In your project's build.gradle.kts
(Kotlin):
...
- If
-PrunningOnCIServer=true
, set-DrunningOnCIServer=true
. - Pass
-Dresources.dir
that points to your resources folder on disk. - Pass
-ea
JVM argument to enable JVM assertions
Examples
$ gradle test -Pcategory=fast // run fast tests
Code Block |
---|
import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @Test public void fastTest() { ... } // runs in fast category @Tag("allocation") @Test public void allocationTest() { ... } // runs in allocation category |
Remote Backend (Advanced users only)
The bambooSync
task provides a remote web server the authority to fail a build using any dynamic requirements it desires. In our experience, this code has a habit of changing frequently, so this logic is abstracted to the following API.
Set the Gradle property ciBackendHost = 0.0.0.0
. This will be places into the following text to form a url: "http://$ciBackendHost/sync"
When the task runs, it sends the project name
and "all tests to tags
" map.
The task then waits for a response with fail
(Boolean), and message
(String). If fail == true
, the Gradle build will fail with the message.