Is it necessary to use the ApplicationTest class in android studio? -


is necessary use applicationtest class in newer version of android studio? (because when created new project, class not in older version of android studio.)

it not necessary have class in project run app.
class used test application in controlled environment.

it may not possible test application on every type of device.
in case, can create customised environments mimic device on want test app.
can create tests different device configurations, databases, , activity lifecycle events.

it extends applicationtestcase class, calls constructor , pass application.class argument.

the applicationtestcase class in turn extends androidtestcase class.

  android.test.androidtestcase      ↳android.test.applicationtestcase<t extends android.app.application>           ↳class applicationtest 

if call createapplication() in test, test case automatically call oncreate() method start application can run in controlled environment. , teardown() method automatically called @ end of test. in turn calls ondestroy() method destroy application.


Comments