Stay organized with collections
Save and categorize content based on your preferences.
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
Classes
Enums
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-05-15 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-15 UTC."],[],[],null,["# androidx.work.testing\n=====================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/androidx/work/testing/package-summary \"View this page in Kotlin\") \\|Java\n\nWorkManager Testing is a library for testing app code that runs using WorkManager.\n\nThis testing library provides a way to manually initialize WorkManager for tests by using [androidx.work.testing.WorkManagerTestInitHelper](/reference/androidx/work/testing/WorkManagerTestInitHelper). Once initialized, you can use [getTestDriver](/reference/androidx/work/testing/WorkManagerTestInitHelper#getTestDriver(android.content.Context)) to drive constraints and timing-related triggers for your background work.\n\nFor ease of testing, this library defaults to using a synchronous [java.util.concurrent.Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html); you can change this in the [androidx.work.Configuration](/reference/androidx/work/Configuration) if you wish.\n\nInterfaces\n----------\n\n|-----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| [TestDriver](/reference/androidx/work/testing/TestDriver) | Additional functionality exposed for [androidx.work.WorkManager](/reference/androidx/work/WorkManager) that are useful in the context of testing. |\n\nClasses\n-------\n\n|-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [SynchronousExecutor](/reference/androidx/work/testing/SynchronousExecutor) | Is an implementation of a [java.util.concurrent.Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html) which executes 's synchronously. |\n| [TestListenableWorkerBuilder](/reference/androidx/work/testing/TestListenableWorkerBuilder) | Builds instances of [androidx.work.ListenableWorker](/reference/androidx/work/ListenableWorker) which can be used for testing. |\n| [TestListenableWorkerBuilderKt](/reference/androidx/work/testing/TestListenableWorkerBuilderKt) | |\n| [TestWorkerBuilder](/reference/androidx/work/testing/TestWorkerBuilder) | Builds instances of [Worker](/reference/androidx/work/Worker) which can be used for testing. |\n| [TestWorkerBuilderKt](/reference/androidx/work/testing/TestWorkerBuilderKt) | |\n| [WorkManagerTestInitHelper](/reference/androidx/work/testing/WorkManagerTestInitHelper) | Helps initialize [androidx.work.WorkManager](/reference/androidx/work/WorkManager) for testing. |\n\nEnums\n-----\n\n|---------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|\n| [WorkManagerTestInitHelper.ExecutorsMode](/reference/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode) | Modes that control which executors are used in tests. |"]]