WorkManagerTestInitHelper.ExecutorsMode


enum WorkManagerTestInitHelper.ExecutorsMode


Modes that control which executors are used in tests.

Summary

Enum Values

LEGACY_OVERRIDE_WITH_SYNCHRONOUS_EXECUTORS

Preserve old behavior of initializeTestWorkManager and initializeTestWorkManager.

PRESERVE_EXECUTORS

Use executors as they are configured in passed Configuration and preserving real main thread.

USE_TIME_BASED_SCHEDULING

Like PRESERVE_EXECUTORS, but uses the real Clock and RunnableScheduler in the provided Configuration instead of the TestDriver setDelayMet() methods to run scheduled work.

Public functions

java-static WorkManagerTestInitHelper.ExecutorsMode!
valueOf(name: String!)

Returns the enum constant of this type with the specified name.

java-static Array<WorkManagerTestInitHelper.ExecutorsMode!>!

Returns an array containing the constants of this enum type, in the order they're declared.

Enum Values

LEGACY_OVERRIDE_WITH_SYNCHRONOUS_EXECUTORS

val WorkManagerTestInitHelper.ExecutorsMode.LEGACY_OVERRIDE_WITH_SYNCHRONOUS_EXECUTORSWorkManagerTestInitHelper.ExecutorsMode

Preserve old behavior of initializeTestWorkManager and initializeTestWorkManager.

In this mode SynchronousExecutor is used instead of main thread. Similarly, SynchronousExecutor is used as getTaskExecutor, unless getTaskExecutor was explicitly set in configuration passed in initializeTestWorkManager

PRESERVE_EXECUTORS

val WorkManagerTestInitHelper.ExecutorsMode.PRESERVE_EXECUTORSWorkManagerTestInitHelper.ExecutorsMode

Use executors as they are configured in passed Configuration and preserving real main thread.

USE_TIME_BASED_SCHEDULING

val WorkManagerTestInitHelper.ExecutorsMode.USE_TIME_BASED_SCHEDULINGWorkManagerTestInitHelper.ExecutorsMode

Like PRESERVE_EXECUTORS, but uses the real Clock and RunnableScheduler in the provided Configuration instead of the TestDriver setDelayMet() methods to run scheduled work.

Work will be passed to RunnableScheduler with appropriate time-based delay, and the RunnableScheduler must reschedule the work itself when the clock delay has passed. setInitialDelayMet and setPeriodDelayMet throw exceptions when this configuration is used.

This mode is intended for integrated fake clock / schedule test frameworks, eg. kotlinx.coroutines.test.StandardTestDispatcherImpl with kotlinx.coroutines.test.TestCoroutineScheduler

Public functions

valueOf

Added in 2.9.0
java-static fun valueOf(name: String!): WorkManagerTestInitHelper.ExecutorsMode!

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Returns
WorkManagerTestInitHelper.ExecutorsMode!

the enum constant with the specified name

Throws
java.lang.IllegalArgumentException

if this enum type has no constant with the specified name

values

Added in 2.9.0
java-static fun values(): Array<WorkManagerTestInitHelper.ExecutorsMode!>!

Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants.

Returns
Array<WorkManagerTestInitHelper.ExecutorsMode!>!

an array containing the constants of this enum type, in the order they're declared