lundi 8 août 2016

How to unit test code wrapped in `runOnUiThread`?

I have a function that calls runOnUiThread as below

fun myFunction(myObject: MyClass, view: MyView) {
    // Do something
    view.getActivity().runOnUiThread {
        myObject.myObjectFunction()
    }
}

I want to UnitTest myFunction to ensure the myObject has call myObjectFunction. But given that it is wrap in runOnUiThread, I can't get to it.

How could I unit test to ensure codes within runOnUiThread is called?

Aucun commentaire:

Enregistrer un commentaire