I've been looking at this answer: https://stackoverflow.com/a/2055455/281460 and it does a great job of explaining the different test classes available for unit/integration testing in Android. One thing it does not explain, though, is the difference between InstrumentationTestCase
and the other test case classes, specifically AndroidTestCase
.
Could someone shed some light on this?
From the docs:
InstrumentationTestCase
A test case that has access to Instrumentation.
AndroidTestCase
Extend this if you need to access Resources or other things that depend on Activity Context.
AndroidTestCase
is pretty well summarized via that link you posted. InstrumentationTestCase
is higher up the class hierarchy from ActivityInstrumentationTestCase2
. It's heavier weight than a plain AndroidTestCase
, but it only exposes an Instrumentation
object and no Activity
, limiting its usefulness.
In reality, you'll probably never need this class, because it doesn't offer much (if any) performance advantage over ActivityInstrumentationTestCase2
, which offers access to an Instrumentation
object itself. In any case, if you want to know what you can do with an Instrumentation
object, check out this or this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With