mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-19 19:42:17 +02:00
test: support class-level Flaky annotation
This commit is contained in:
parent
62eff67e2f
commit
84730bec3c
@ -52,7 +52,7 @@ annotation class Flaky(val os: OS, val message: String = "")
|
||||
class IgnoreFlakyTestsInCIRule : TestRule {
|
||||
override fun apply(base: Statement, description: Description): Statement {
|
||||
if (!isRunningUnderCI) return base
|
||||
val annotation = description.getAnnotation(Flaky::class.java) ?: return base
|
||||
val annotation = description.getFlakyAnnotation() ?: return base
|
||||
if (!annotation.os.isRunning()) return base
|
||||
return object : Statement() {
|
||||
override fun evaluate() {
|
||||
@ -62,6 +62,14 @@ class IgnoreFlakyTestsInCIRule : TestRule {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of [Flaky] for the test if annotated,
|
||||
* preferring the method-level annotation over the class-level annotation
|
||||
*/
|
||||
private fun Description.getFlakyAnnotation(): Flaky? {
|
||||
return getAnnotation(Flaky::class.java) ?: this.testClass.getAnnotation(Flaky::class.java)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val isRunningUnderCI: Boolean = BuildConfig.CI
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user