Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

WorkManagerTestInitHelper

public final class WorkManagerTestInitHelper
extends Object

java.lang.Object
   ↳ androidx.work.testing.WorkManagerTestInitHelper


Helps initialize WorkManager for testing.

Summary

Public methods

static TestDriver getTestDriver(Context context)
static TestDriver getTestDriver()

This method is deprecated. Call getTestDriver(Context) instead.

static void initializeTestWorkManager(Context context)

Initializes a test WorkManager with a SynchronousExecutor.

static void initializeTestWorkManager(Context context, Configuration configuration)

Initializes a test WorkManager with a user-specified Configuration.

Inherited methods

Public methods

getTestDriver

public static TestDriver getTestDriver (Context context)

Parameters
context Context

Returns
TestDriver An instance of TestDriver. This exposes additional functionality that is useful in the context of testing when using WorkManager.

getTestDriver

public static TestDriver getTestDriver ()

This method is deprecated.
Call getTestDriver(Context) instead.

Returns
TestDriver An instance of TestDriver. This exposes additional functionality that is useful in the context of testing when using WorkManager.

initializeTestWorkManager

public static void initializeTestWorkManager (Context context)

Initializes a test WorkManager with a SynchronousExecutor.

Parameters
context Context: The application Context

initializeTestWorkManager

public static void initializeTestWorkManager (Context context, 
                Configuration configuration)

Initializes a test WorkManager with a user-specified Configuration.

Parameters
context Context: The application Context

configuration Configuration: The Configuration