Google is committed to advancing racial equity for Black communities. See how.

androidx.work.testing

Interfaces

TestDriver

Additional functionality exposed for androidx.work.WorkManager that are useful in the context of testing.

Classes

SynchronousExecutor

Is an implementation of a java.util.concurrent.Executor which executes 's synchronously.

TestListenableWorkerBuilder

Builds instances of androidx.work.ListenableWorker which can be used for testing.

TestWorkerBuilder

Builds instances of Worker which can be used for testing.

WorkManagerTestInitHelper

Helps initialize androidx.work.WorkManager for testing.

Top-level functions summary

TestListenableWorkerBuilder<W>
TestListenableWorkerBuilder(context: Context, inputData: Data = Data.EMPTY, tags: List<String> = emptyList(), runAttemptCount: Int = 1, triggeredContentUris: List<Uri> = emptyList(), triggeredContentAuthorities: List<String> = emptyList())

Builds an instance of TestListenableWorkerBuilder.

TestWorkerBuilder<W>
TestWorkerBuilder(context: Context, executor: Executor, inputData: Data = Data.EMPTY, tags: List<String> = emptyList(), runAttemptCount: Int = 1, triggeredContentUris: List<Uri> = emptyList(), triggeredContentAuthorities: List<String> = emptyList())

Builds an instance of TestWorkerBuilder.

Top-level functions

TestListenableWorkerBuilder

inline fun <reified W : ListenableWorker> TestListenableWorkerBuilder(
    context: Context,
    inputData: Data = Data.EMPTY,
    tags: List<String> = emptyList(),
    runAttemptCount: Int = 1,
    triggeredContentUris: List<Uri> = emptyList(),
    triggeredContentAuthorities: List<String> = emptyList()
): TestListenableWorkerBuilder<W>

Builds an instance of TestListenableWorkerBuilder.

Parameters
W The subtype of ListenableWorker
context: Context The application Context
inputData: Data = Data.EMPTY The input data for the ListenableWorker
runAttemptCount: Int = 1 The run attempt count of the ListenableWorker
triggeredContentUris: List<Uri> = emptyList() The list of triggered content Uris
triggeredContentAuthorities: List<String> = emptyList() The list of triggered content authorities
Return
The instance of TestListenableWorkerBuilder

TestWorkerBuilder

inline fun <reified W : Worker> TestWorkerBuilder(
    context: Context,
    executor: Executor,
    inputData: Data = Data.EMPTY,
    tags: List<String> = emptyList(),
    runAttemptCount: Int = 1,
    triggeredContentUris: List<Uri> = emptyList(),
    triggeredContentAuthorities: List<String> = emptyList()
): TestWorkerBuilder<W>

Builds an instance of TestWorkerBuilder.

Parameters
W The subtype of Worker
context: Context The application Context
executor: Executor The Executor that the Worker runs on
inputData: Data = Data.EMPTY The input data for the Worker
runAttemptCount: Int = 1 The run attempt count of the Worker
triggeredContentUris: List<Uri> = emptyList() The list of triggered content Uris
triggeredContentAuthorities: List<String> = emptyList() The list of triggered content authorities
Return
The instance of TestWorkerBuilder