@Deprecated public abstract class ApplicationTestCase<T extends Application> extends AndroidTestCase
Lifecycle Support.
Every Application is designed to be accessed within a specific sequence of
method calls (see Application
for more details).
In order to support the lifecycle of a Application, this test case will make the
following calls at the following times.
createApplication()
. This gives you a chance
to set up or adjust any additional framework or test logic before
onCreate().tearDown()
method is
automatically called, and it will stop & destroy your application by calling its
onDestroy() method.Dependency Injection.
Every Application has one inherent dependency, the Context
in
which it runs.
This framework allows you to inject a modified, mock, or isolated replacement for this
dependencies, and thus perform a true unit test.
If simply run your tests as-is, your Application will be injected with a fully-functional
Context.
You can create and inject alternative types of Contexts by calling
setContext()
. You must do this before calling
createApplication()
. The test framework provides a
number of alternatives for Context, including MockContext
,
RenamingDelegatingContext
, and
ContextWrapper
.
mContext
Constructor and Description |
---|
ApplicationTestCase(Class<T> applicationClass)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
createApplication()
Deprecated.
Start the Application under test, in the same way as if it was started by the system.
|
T |
getApplication()
Deprecated.
|
Context |
getSystemContext()
Deprecated.
Return a real (not mocked or instrumented) system Context that can be used when generating
Mock or other Context objects for your Application under test.
|
protected void |
setUp()
Deprecated.
This will do the work to instantiate the Application under test.
|
protected void |
tearDown()
Deprecated.
Shuts down the Application under test.
|
protected void |
terminateApplication()
Deprecated.
This will make the necessary calls to terminate the Application under test (it will
call onTerminate().
|
void |
testApplicationTestCaseSetUpProperly()
Deprecated.
This test simply confirms that the Application class can be instantiated properly.
|
assertActivityRequiresPermission, assertReadingContentUriRequiresPermission, assertWritingContentUriRequiresPermission, getContext, getTestContext, scrubClass, setContext, setTestContext, testAndroidTestCaseSetupProperly
public T getApplication()
protected void setUp() throws Exception
setUp
in class AndroidTestCase
Exception
protected final void createApplication()
tearDown()
. If you wish to inject a specialized Context for your
test, by calling setContext()
,
you must do so before calling this method.protected final void terminateApplication()
tearDown()
, but
you can call it directly from your test in order to check for proper shutdown behaviors.protected void tearDown() throws Exception
tearDown
in class AndroidTestCase
Exception
public Context getSystemContext()