Stay organized with collections
Save and categorize content based on your preferences.
FlakyTest
@Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) class FlakyTest
This annotation can be used on an android.test.InstrumentationTestCase
's test methods. When the annotation is present, the test method is re-executed if the test fails. The total number of executions is specified by the tolerance and defaults to 1.
Summary
Properties |
Int |
Indicates how many times a test can run and fail before being reported as a failed test.
|
Public constructors
Properties
tolerance
val tolerance: Int
Deprecated: Deprecated in Java.
Indicates how many times a test can run and fail before being reported as a failed test. If the tolerance factor is less than 1, the test runs only once.
Return |
Int |
The total number of allowed run, the default is 1. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# FlakyTest\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nFlakyTest\n=========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/test/FlakyTest \"View this page in Java\") \n\n```\n@Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) class FlakyTest\n```\n\n|-----------------------------|\n| [android.test.FlakyTest](#) |\n\n*** ** * ** ***\n\n| **This annotation was deprecated in API level 24.**\n|\n| Use [FlakyTest](https://developer.android.com/reference/android/support/test/filters/FlakyTest.html) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library/index.html).\n\nThis annotation can be used on an [android.test.InstrumentationTestCase](/reference/kotlin/android/test/InstrumentationTestCase)'s test methods. When the annotation is present, the test method is re-executed if the test fails. The total number of executions is specified by the tolerance and defaults to 1.\n\nSummary\n-------\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [FlakyTest](#FlakyTest(kotlin.Int))`(`tolerance:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` This annotation can be used on an [android.test.InstrumentationTestCase](/reference/kotlin/android/test/InstrumentationTestCase)'s test methods. |\n\n| Properties ||\n|----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [tolerance](#tolerance:kotlin.Int) Indicates how many times a test can run and fail before being reported as a failed test. |\n\nPublic constructors\n-------------------\n\n### FlakyTest\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nFlakyTest(tolerance: Int)\n```\n\n**Deprecated:** *Use [FlakyTest](https://developer.android.com/reference/android/support/test/filters/FlakyTest.html) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library/index.html).*\n\nThis annotation can be used on an [android.test.InstrumentationTestCase](/reference/kotlin/android/test/InstrumentationTestCase)'s test methods. When the annotation is present, the test method is re-executed if the test fails. The total number of executions is specified by the tolerance and defaults to 1.\n\nProperties\n----------\n\n### tolerance\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nval tolerance: Int\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nIndicates how many times a test can run and fail before being reported as a failed test. If the tolerance factor is less than 1, the test runs only once.\n\n| Return ||\n|----------------------------------------------------------------------------|----------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The total number of allowed run, the default is 1. |"]]