Use TargetSetupError for ConnectivityCheck
If the preparer throws AssertionError, tests will still
be retried without re-running the preparer. It needs
to throw TargetSetupError to indicate that setup failed.
Change-Id: Id01845536a216e1a3ca1c671c97f7bcd992c354e
Fixes: 254542801
Test: atest
diff --git a/staticlibs/testutils/host/com/android/testutils/ConnectivityCheckTargetPreparer.kt b/staticlibs/testutils/host/com/android/testutils/ConnectivityCheckTargetPreparer.kt
index 85589ad..ccc4064 100644
--- a/staticlibs/testutils/host/com/android/testutils/ConnectivityCheckTargetPreparer.kt
+++ b/staticlibs/testutils/host/com/android/testutils/ConnectivityCheckTargetPreparer.kt
@@ -21,6 +21,7 @@
import com.android.tradefed.result.CollectingTestListener
import com.android.tradefed.result.ddmlib.DefaultRemoteAndroidTestRunner
import com.android.tradefed.targetprep.BaseTargetPreparer
+import com.android.tradefed.targetprep.TargetSetupError
import com.android.tradefed.targetprep.suite.SuiteApkInstaller
private const val CONNECTIVITY_CHECKER_APK = "ConnectivityChecker.apk"
@@ -52,13 +53,14 @@
val receiver = CollectingTestListener()
if (!testInformation.device.runInstrumentationTests(runner, receiver)) {
- throw AssertionError("Device state check failed to complete")
+ throw TargetSetupError("Device state check failed to complete",
+ testInformation.device.deviceDescriptor)
}
val runResult = receiver.currentRunResults
if (runResult.isRunFailure) {
- throw AssertionError("Failed to check device state before the test: " +
- runResult.runFailureMessage)
+ throw TargetSetupError("Failed to check device state before the test: " +
+ runResult.runFailureMessage, testInformation.device.deviceDescriptor)
}
if (!runResult.hasFailedTests()) return
@@ -67,7 +69,8 @@
else "$testDescription: ${testResult.stackTrace}"
}.joinToString("\n")
- throw AssertionError("Device setup checks failed. Check the test bench: \n$errorMsg")
+ throw TargetSetupError("Device setup checks failed. Check the test bench: \n$errorMsg",
+ testInformation.device.deviceDescriptor)
}
override fun tearDown(testInformation: TestInformation?, e: Throwable?) {