WorkManager: Call doWork() immediately for test purposes
up vote
1
down vote
favorite
If I have a PeriodicWorkRequest
I can set a time intervall - which minimum is 15 minutes.
But how can I test if my doWork()
method is working without waiting for 15 minutes?
Is it maybe possible to use OneTimeWorkRequest
for test purposes?
Thanks in advance
android android-architecture-components android-workmanager
add a comment |
up vote
1
down vote
favorite
If I have a PeriodicWorkRequest
I can set a time intervall - which minimum is 15 minutes.
But how can I test if my doWork()
method is working without waiting for 15 minutes?
Is it maybe possible to use OneTimeWorkRequest
for test purposes?
Thanks in advance
android android-architecture-components android-workmanager
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
If I have a PeriodicWorkRequest
I can set a time intervall - which minimum is 15 minutes.
But how can I test if my doWork()
method is working without waiting for 15 minutes?
Is it maybe possible to use OneTimeWorkRequest
for test purposes?
Thanks in advance
android android-architecture-components android-workmanager
If I have a PeriodicWorkRequest
I can set a time intervall - which minimum is 15 minutes.
But how can I test if my doWork()
method is working without waiting for 15 minutes?
Is it maybe possible to use OneTimeWorkRequest
for test purposes?
Thanks in advance
android android-architecture-components android-workmanager
android android-architecture-components android-workmanager
edited Nov 5 at 17:30
ianhanniballake
101k14208220
101k14208220
asked Nov 5 at 17:25
hideous
456
456
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Yes, there is nothing stopping you from using OneTimeWorkRequest
.
val work = OneTimeWorkRequest.Builder(MyWorker::class.java).build()
WorkManager.getInstance().enqueue(work)
Bear in mind, that this will not allow you to test that your Worker
will fire after a set number of minutes, like when using PeriodicWorkRequest
. It will however let you test that your code works, without needing to wait.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Yes, there is nothing stopping you from using OneTimeWorkRequest
.
val work = OneTimeWorkRequest.Builder(MyWorker::class.java).build()
WorkManager.getInstance().enqueue(work)
Bear in mind, that this will not allow you to test that your Worker
will fire after a set number of minutes, like when using PeriodicWorkRequest
. It will however let you test that your code works, without needing to wait.
add a comment |
up vote
1
down vote
accepted
Yes, there is nothing stopping you from using OneTimeWorkRequest
.
val work = OneTimeWorkRequest.Builder(MyWorker::class.java).build()
WorkManager.getInstance().enqueue(work)
Bear in mind, that this will not allow you to test that your Worker
will fire after a set number of minutes, like when using PeriodicWorkRequest
. It will however let you test that your code works, without needing to wait.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Yes, there is nothing stopping you from using OneTimeWorkRequest
.
val work = OneTimeWorkRequest.Builder(MyWorker::class.java).build()
WorkManager.getInstance().enqueue(work)
Bear in mind, that this will not allow you to test that your Worker
will fire after a set number of minutes, like when using PeriodicWorkRequest
. It will however let you test that your code works, without needing to wait.
Yes, there is nothing stopping you from using OneTimeWorkRequest
.
val work = OneTimeWorkRequest.Builder(MyWorker::class.java).build()
WorkManager.getInstance().enqueue(work)
Bear in mind, that this will not allow you to test that your Worker
will fire after a set number of minutes, like when using PeriodicWorkRequest
. It will however let you test that your code works, without needing to wait.
answered Nov 7 at 8:56
Knossos
11.2k73970
11.2k73970
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53159273%2fworkmanager-call-dowork-immediately-for-test-purposes%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password