androidx.work.testing

WorkManager Testing is a library for testing app code that runs using WorkManager.

This testing library provides a way to manually initialize WorkManager for tests by using androidx.work.testing.WorkManagerTestInitHelper. Once initialized, you can use getTestDriver to drive constraints and timing-related triggers for your background work.

For ease of testing, this library defaults to using a synchronous java.util.concurrent.Executor; you can change this in the androidx.work.Configuration if you wish.

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.

TestListenableWorkerBuilderKt
TestWorkerBuilder

Builds instances of Worker which can be used for testing.

TestWorkerBuilderKt
WorkManagerTestInitHelper

Helps initialize androidx.work.WorkManager for testing.

Enums

WorkManagerTestInitHelper.ExecutorsMode

Modes that control which executors are used in tests.