TestWorkerBuilder


public class TestWorkerBuilderWorker> extends TestListenableWorkerBuilder

Builds instances of Worker which can be used for testing.

Parameters
Worker>

The actual subtype of Worker

Summary

Public methods

static @NonNull TestWorkerBuilder<Worker>
from(
    @NonNull Context context,
    @NonNull WorkRequest workRequest,
    @NonNull Executor executor
)

Creates a new instance of a TestWorkerBuilder from a WorkRequest that runs on the given Executor.

static @NonNull TestWorkerBuilder
Worker> from(
    @NonNull Context context,
    @NonNull Class workerClass,
    @NonNull Executor executor
)

Creates a new instance of a TestWorkerBuilder with the worker Class that runs on the given Executor.

Inherited methods

From androidx.work.testing.TestListenableWorkerBuilder
@NonNull W

Builds the ListenableWorker.

static @NonNull TestListenableWorkerBuilder<ListenableWorker>
from(@NonNull Context context, @NonNull WorkRequest workRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

static @NonNull TestListenableWorkerBuilder
ListenableWorker> from(
    @NonNull Context context,
    @NonNull Class workerClass
)

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

@NonNull TestListenableWorkerBuilder

Sets the ForegroundUpdater to be used to construct the androidx.work.ListenableWorker.

@NonNull TestListenableWorkerBuilder

Sets the id for this unit of work.

@NonNull TestListenableWorkerBuilder

Adds input Data to the work.

@NonNull TestListenableWorkerBuilder
@RequiresApi(value = 28)
setNetwork(@NonNull Network network)

Sets the network associated with this unit of work.

@NonNull TestListenableWorkerBuilder

Sets the ProgressUpdater to be used to construct the androidx.work.ListenableWorker.

@NonNull TestListenableWorkerBuilder
setRunAttemptCount(int runAttemptCount)

Sets the initial run attempt count for this work.

@NonNull TestListenableWorkerBuilder

Sets the tags associated with this unit of work.

@NonNull TestListenableWorkerBuilder

Sets the authorities for content Uri's associated with this unit of work.

@NonNull TestListenableWorkerBuilder
@RequiresApi(value = 24)
setTriggeredContentUris(@NonNull List<Uri> contentUris)

Sets the list of Content Uris associated with this unit of work.

@NonNull TestListenableWorkerBuilder

Sets the WorkerFactory to be used to construct the androidx.work.ListenableWorker.

Public methods

from

Added in 2.1.0
public static @NonNull TestWorkerBuilder<Workerfrom(
    @NonNull Context context,
    @NonNull WorkRequest workRequest,
    @NonNull Executor executor
)

Creates a new instance of a TestWorkerBuilder from a WorkRequest that runs on the given Executor.

Parameters
@NonNull Context context

The Context

@NonNull WorkRequest workRequest

The WorkRequest

@NonNull Executor executor

The Executor

Returns
@NonNull TestWorkerBuilder<Worker>

The new instance of a TestWorkerBuilder

from

Added in 2.1.0
public static @NonNull TestWorkerBuilder Worker> from(
    @NonNull Context context,
    @NonNull Class workerClass,
    @NonNull Executor executor
)

Creates a new instance of a TestWorkerBuilder with the worker Class that runs on the given Executor.

Parameters
@NonNull Context context

The Context

@NonNull Class workerClass

The subtype of Worker being built

@NonNull Executor executor

The Executor

Returns
@NonNull TestWorkerBuilder

The new instance of a TestWorkerBuilder