# WorkManagerTestInitHelper.ExecutorsMode

Artifact: [androidx.work:work-testing](https://developer.android.com/jetpack/androidx/releases/work) [View Source](https://cs.android.com/search?q=file:androidx/work/testing/WorkManagerTestInitHelper.java+class:androidx.work.testing.WorkManagerTestInitHelper.ExecutorsMode) Added in [2.9.0](https://developer.android.com/jetpack/androidx/releases/work#2.9.0)

*** ** * ** ***

<br />

```
enum WorkManagerTestInitHelper.ExecutorsMode
```

<br />

*** ** * ** ***

Modes that control which executors are used in tests.

## Summary

| ### Enum Values |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode#LEGACY_OVERRIDE_WITH_SYNCHRONOUS_EXECUTORS` | Preserve old behavior of `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper#initializeTestWorkManager(android.content.Context)` and `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper#initializeTestWorkManager(android.content.Context,androidx.work.Configuration)`. |
| `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode#PRESERVE_EXECUTORS` | Use executors as they are configured in passed `https://developer.android.com/reference/kotlin/androidx/work/Configuration` and preserving real main thread. |
| `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode#USE_TIME_BASED_SCHEDULING` | Like `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode#PRESERVE_EXECUTORS`, but uses the real Clock and RunnableScheduler in the provided `https://developer.android.com/reference/kotlin/androidx/work/Configuration` instead of the `https://developer.android.com/reference/kotlin/androidx/work/testing/TestDriver` setDelayMet() methods to run scheduled work. |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode!` | `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode#valueOf(java.lang.String)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns the enum constant of this type with the specified name. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode!>!` | `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode#values()()` 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_EXECUTORS: WorkManagerTestInitHelper.ExecutorsMode
```

Preserve old behavior of `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper#initializeTestWorkManager(android.content.Context)` and `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper#initializeTestWorkManager(android.content.Context,androidx.work.Configuration)`.

In this mode `https://developer.android.com/reference/kotlin/androidx/work/testing/SynchronousExecutor` is used instead of main thread. Similarly, `https://developer.android.com/reference/kotlin/androidx/work/testing/SynchronousExecutor` is used as `https://developer.android.com/reference/kotlin/androidx/work/Configuration#getTaskExecutor()`, unless `https://developer.android.com/reference/kotlin/androidx/work/Configuration#getTaskExecutor()` was explicitly set in `configuration` passed in `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper#initializeTestWorkManager(android.content.Context,androidx.work.Configuration,androidx.work.testing.WorkManagerTestInitHelper.ExecutorsMode)`

### PRESERVE_EXECUTORS

```
val WorkManagerTestInitHelper.ExecutorsMode.PRESERVE_EXECUTORS: WorkManagerTestInitHelper.ExecutorsMode
```

Use executors as they are configured in passed `https://developer.android.com/reference/kotlin/androidx/work/Configuration` and preserving real main thread.

### USE_TIME_BASED_SCHEDULING

```
val WorkManagerTestInitHelper.ExecutorsMode.USE_TIME_BASED_SCHEDULING: WorkManagerTestInitHelper.ExecutorsMode
```

Like `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode#PRESERVE_EXECUTORS`, but uses the real Clock and RunnableScheduler in the provided `https://developer.android.com/reference/kotlin/androidx/work/Configuration` instead of the `https://developer.android.com/reference/kotlin/androidx/work/testing/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. `https://developer.android.com/reference/kotlin/androidx/work/testing/TestDriver#setInitialDelayMet(java.util.UUID)` and `https://developer.android.com/reference/kotlin/androidx/work/testing/TestDriver#setPeriodDelayMet(java.util.UUID)` 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 |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode!` | the enum constant with the specified name |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | 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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/work/testing/WorkManagerTestInitHelper.ExecutorsMode!>!` | an array containing the constants of this enum type, in the order they're declared |