Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/groovy/com/stanfy/spoon/gradle/SpoonExtension.groovy
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ class SpoonExtension {

/** Grants all permisions for Android M >= devices */
boolean grantAllPermissions

/** Tests re-run count to re-run tests in case of failure in order to eliminate flakiness */
int reRunsCount = 1;
}
1 change: 1 addition & 0 deletions src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class SpoonPlugin implements Plugin<Project> {
codeCoverage = config.codeCoverage
shard = config.shard
grantAllPermissions = config.grantAllPermissions
reRunsCount = config.reRunsCount
if (config.adbTimeout != -1) {
// Timeout is defined in seconds in the config.
adbTimeout = config.adbTimeout * 1000
Expand Down
9 changes: 9 additions & 0 deletions src/main/groovy/com/stanfy/spoon/gradle/SpoonRunTask.groovy
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class SpoonRunTask extends DefaultTask implements VerificationTask {
/** Grants all permisions for Android M >= devices */
boolean grantAllPermissions

/** Tests re-run count to re-run tests in case of failure in order to eliminate flakiness */
int reRunsCount;

@TaskAction
void runSpoon() {
LOG.info("Run instrumentation tests $instrumentationApk for app $applicationApk")
Expand Down Expand Up @@ -189,6 +192,12 @@ class SpoonRunTask extends DefaultTask implements VerificationTask {
}

boolean success = runBuilder.build().run()
int runsCount = 1;
while(!success && reRunsCount > runsCount) {
LOG.info("Tests failed. Trying to re-run now")
success = runBuilder.build().run()
runsCount++
}

if (!success && !ignoreFailures) {
throw new GradleException("Tests failed! See ${output}/index.html")
Expand Down