RetryTestRule: don't modify in scripts, use buildConfigField instead

Modifying code in scripts is bad

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2022-03-01 16:31:26 +01:00 committed by Álvaro Brey (Rebase PR Action)
parent 421a672e1d
commit b5f727f945
3 changed files with 8 additions and 3 deletions

View file

@ -21,7 +21,6 @@ steps:
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
- sed -i s"#server#server#" gradle.properties
- sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
- ./gradlew assembleGplay
- ./gradlew assembleGplayDebug
- scripts/wait_for_emulator.sh
@ -85,7 +84,6 @@ steps:
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
- sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
- scripts/runCombinedTest.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER
services:

View file

@ -111,6 +111,8 @@ android {
minSdkVersion 23
targetSdkVersion 30
buildConfigField 'boolean', 'CI', ciBuild.toString()
// arguments to be passed to functional tests
testInstrumentationRunner "com.nextcloud.client.ScreenshotTestRunner"
testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}"
@ -235,6 +237,7 @@ android {
htmlOutput file("$project.buildDir/reports/lint/lint.html")
htmlReport true
}
}
dependencies {

View file

@ -23,6 +23,7 @@
package com.nextcloud.client
import android.util.Log
import com.owncloud.android.BuildConfig
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
@ -30,10 +31,13 @@ import org.junit.runners.model.Statement
/**
* C&p from https://stackoverflow.com/questions/45635833/how-can-i-use-flakytest-annotation-now on 18.03.2020
*/
class RetryTestRule(val retryCount: Int = 1) : TestRule {
class RetryTestRule(val retryCount: Int = defaultRetryValue) : TestRule {
companion object {
private val TAG = RetryTestRule::class.java.simpleName
@Suppress("MagicNumber")
private val defaultRetryValue: Int = if (BuildConfig.CI) 5 else 1
}
override fun apply(base: Statement, description: Description): Statement {