BackupRestoreExtension


class BackupRestoreExtension : ParameterResolver


A JUnit 5 Jupiter extension that resolves BackupRestoreController test parameters.

It automatically initializes ADB sessions, selects an online Android device matching target API and serial constraints (specified via system properties or Device annotations), handles automatic APK installation for tested and test packages, proactively dismisses lockscreens/keyguards, and sets up data isolation (e.g. running pm clear) prior to test execution.

Each controller targets the app named by the test class's BackupRestoreConfig. Without one, it targets the tested app that the test suite properties name.

Summary

Public constructors

Creates a standalone extension, which manages its own ADB session.

Creates an extension that integrates with an existing shared AdbSession.

Public functions

open Any
resolveParameter(
    parameterContext: ParameterContext?,
    extensionContext: ExtensionContext?
)
open Boolean
supportsParameter(
    parameterContext: ParameterContext?,
    extensionContext: ExtensionContext?
)

Public constructors

BackupRestoreExtension

Added in 1.0.0-alpha03
BackupRestoreExtension()

Creates a standalone extension, which manages its own ADB session.

All standalone extensions in a test run share one session. It is created when a test first requests a BackupRestoreController and closed when the test run ends.

BackupRestoreExtension

Added in 1.0.0-alpha03
BackupRestoreExtension(adbSession: AdbSession)

Creates an extension that integrates with an existing shared AdbSession.

In this shared mode, the extension integrates with a shared ADB session provided by an external framework or test suite. The lifecycle of this session (creation and close/cleanup) is managed externally, meaning the extension will not close or dispose of the shared session.

Parameters
adbSession: AdbSession

The active AdbSession to be used by the extension.

Public functions

resolveParameter

Added in 1.0.0-alpha03
open fun resolveParameter(
    parameterContext: ParameterContext?,
    extensionContext: ExtensionContext?
): Any

supportsParameter

Added in 1.0.0-alpha03
open fun supportsParameter(
    parameterContext: ParameterContext?,
    extensionContext: ExtensionContext?
): Boolean