Skip to content

Instantly share code, notes, and snippets.

@keiththompson
Last active December 13, 2021 09:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keiththompson/e7b6932bfbf515a5c2b656f49b202825 to your computer and use it in GitHub Desktop.
Save keiththompson/e7b6932bfbf515a5c2b656f49b202825 to your computer and use it in GitHub Desktop.
CircleCI’s parallelization: junit tests with Gradle
#!/usr/bin/env bash
testFiles=$(find ./{app}/src/test/java/{your}/{package}/{name} -name '*.java' | sort | awk "NR % ${CIRCLE_NODE_TOTAL} == ${CIRCLE_NODE_INDEX}")
./gradlew test -PtestFilter="$testFiles"
testOptions {
unitTests.all {
if (project.hasProperty("testFilter")) {
ArrayList props = project.getProperties().get("testFilter")
.replaceAll("./app/src/test/java/{your}/{package}/{name}/", "**/")
.replaceAll(".java", ".class")
.split("\\s+")
for (String item : props) {
include item
}
}
}
}
test:
override:
- sh ./balancing.sh:
parallel: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment