Difference between InstrumentationTestCase and AndroidTestCase

I was looking at this answer: https://stackoverflow.com/a/212944/ and it does an excellent job explaining the various test classes available for unit / integration testing in Android. However, this alone does not explain the difference between InstrumentationTestCase and other classes of test cases, in particular AndroidTestCase .

Can someone shed some light on this?

+6
source share
1 answer

From the docs:

InstrumentationTestCase

Test with access to Tools.

AndroidTestCase

Extend this if you need to access Resources or other things that depend on the context of activity.

AndroidTestCase pretty well on the link you posted. InstrumentationTestCase above the class hierarchy from ActivityInstrumentationTestCase2 . This is a heavier weight than the simple AndroidTestCase , but it only provides an Instrumentation and Activity object that limits its usefulness.

In reality, you probably will never need this class, because it does not provide many advantages (if any) compared to ActivityInstrumentationTestCase2 , which offers access to the Instrumentation object itself. In any case, if you want to know what you can do with the Instrumentation object, check out this or this .

+6
source

Source: https://habr.com/ru/post/976986/


All Articles