-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit Test suites for AsyncTasks #244
Conversation
Can one of the admins verify this patch? Also need an authorization to run tests. |
Hi @wbrunette @Lamouresparus , created the test for async task classes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your setup creates a background task each time. Does the task run? What happens if you cancel the task? What about making sure the task finishes?
} | ||
|
||
@Test | ||
public void checkIfResolutionListener_isAvailable() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test does not seem to verify any behavior. Normally you see an assert to verify it's working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a doubt in this one, I actually wanted to test if resolutionListener will set to null after calling clearResolutionListener according to the class behavior, but I can't cause it can't be accessed. Can I add a getResolutionListener() to test the functionality of these two functions?
public ResolutionListener getResolutionListener() { return rl; }
|
||
@Test | ||
public void checkIfResolutionListener_isAvailable() { | ||
conflictResolutionListTask.setResolutionListener(resolutionListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test does not seem to verify any behavior. Normally you see an assert to verify it's working
Yeah, ur right!! added the asynctask.execute to make sure task runs and asynctask.cancel to make sure asynctask thread stops. |
Hi @wbrunette, There's still the error of OdkConnectionFactorySingleton not initialized as it's a final class and mockito can't mock it. I'll look into the issue. |
@sanyud24 did you solve the issue on of the mockito? |
Yeah @wbrunette , I'm almost done with it. |
Hi, @wbrunette fixed this PR and added a base test class. |
Tested custom AsyncTask classes.
package org.opendatakit.services.resolve.task
CheckpointResolutionListTask
ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED)
to change the"card-status = mounted" and to set mock external storage.
ConflictResolutionListTask