While looking up for unit testing for Android applications, I came across a lot of voices over how it is difficult to test-unit an Android app.
For example:
Dependency issue - why is this a problem for unit-testing in Android?
What would be "dependent" in this case that testing is impossible?
For example:
public String getName()
{
mName = "Android";
return mName;
}
Would this be hard to unit-test? If so, why? Is it because it "depends" on String
class? But why can't it depend on String
class as far as unit-testing is concerned? If my sample above and my understanding is off, please correct me.
Another issue I heard is:
"the android.jar is not on the machine! It's on the emulator, that's why it makes unit-testing on Android a living hell!"
But, why would it be a living hell if it is installed on the emulator?
Another issue I hear the most is this:
The Activity
class. Some say it is a view, some say it is a controller because it handles creation of objects, too. That's why this is an issue. But I don't get it at all. Why would this cause problem?
Another thing I am trying to get my head around is:
Why in both Android and Java they need to "mock" a class to unit-test? Why? In Objective-C
for example, I have never heard of a need such as this.
Thank you.