attach

suspend fun <R> attach(serial: String, timeouts: Timeouts = Timeouts(), options: DeviceOptions = DeviceOptions(), block: suspend (Device) -> R): R(source)

Attaches serial (attachDevice), runs block with the device and always detaches it afterwards. Runs inside the caller's tapTest / tapScope, or installs a TapContext of its own when there is none, so a script needs no tapScope. A block failure wins and a detach failure after it is added as suppressed; when block succeeds, a detach failure (including quarantine) is thrown.