BackupRestoreExtension


public final class BackupRestoreExtension implements 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 methods

@NonNull Object
resolveParameter(
    ParameterContext parameterContext,
    ExtensionContext extensionContext
)
boolean
supportsParameter(
    ParameterContext parameterContext,
    ExtensionContext extensionContext
)

Public constructors

BackupRestoreExtension

Added in 1.0.0-alpha03
public 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
public BackupRestoreExtension(@NonNull 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
@NonNull AdbSession adbSession

The active AdbSession to be used by the extension.

Public methods

resolveParameter

Added in 1.0.0-alpha03
public @NonNull Object resolveParameter(
    ParameterContext parameterContext,
    ExtensionContext extensionContext
)

supportsParameter

Added in 1.0.0-alpha03
public boolean supportsParameter(
    ParameterContext parameterContext,
    ExtensionContext extensionContext
)