I'm working with unit testing for the first time and I'm lost with some specific cases.
Despite reading a lot I'm confused about how to test a function like this in Android:
void myFunction() {
MyThread myThread = new MyThread();
myThread();
}
class MyThread extends Thread {
public void run() {
Looper.prepare();
// Tasks to do in background
handler.sendEmptyMessage(101);
}
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 101:
// Get the results
// Update UI
}
}
};
I've read about "CountDownLatch" as in this SO answer https://stackoverflow.com/a/5722193/1639825 but I don't know how to use this.