The Android Developer Challenge is back! Submit your idea before December 2.

WorkManagerTestInitHelper

class WorkManagerTestInitHelper
kotlin.Any
   ↳ androidx.work.testing.WorkManagerTestInitHelper

Helps initialize androidx.work.WorkManager for testing.

Summary

Public methods

static TestDriver?

static TestDriver?
getTestDriver(@NonNull context: Context)

static Unit

Initializes a test androidx.work.WorkManager with a SynchronousExecutor.

static Unit
initializeTestWorkManager(@NonNull context: Context, @NonNull configuration: Configuration)

Initializes a test androidx.work.WorkManager with a user-specified androidx.work.Configuration.

Public methods

getTestDriver

@Nullable static fun getTestDriver(): TestDriver?

Deprecated: Call WorkManagerTestInitHelper#getTestDriver(Context) instead.

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

getTestDriver

@Nullable static fun getTestDriver(@NonNull context: Context): TestDriver?
Return
TestDriver?: An instance of TestDriver. This exposes additional functionality that is useful in the context of testing when using WorkManager.

initializeTestWorkManager

static fun initializeTestWorkManager(@NonNull context: Context): Unit

Initializes a test androidx.work.WorkManager with a SynchronousExecutor.

Parameters
context Context: The application Context

initializeTestWorkManager

static fun initializeTestWorkManager(@NonNull context: Context, @NonNull configuration: Configuration): Unit

Initializes a test androidx.work.WorkManager with a user-specified androidx.work.Configuration.

Parameters
context Context: The application Context
configuration Context: The androidx.work.Configuration