Methods Summary |
---|
public android.content.Context | getContext()
return mContext;
|
protected void | scrubClass(java.lang.Class testCaseClass)This function is called by various TestCase implementations, at tearDown() time, in order
to scrub out any class variables. This protects against memory leaks in the case where a
test case creates a non-static inner class (thus referencing the test case) and gives it to
someone else to hold onto.
final Field[] fields = getClass().getDeclaredFields();
for (Field field : fields) {
final Class<?> fieldClass = field.getDeclaringClass();
if (testCaseClass.isAssignableFrom(fieldClass) && !field.getType().isPrimitive()) {
try {
field.setAccessible(true);
field.set(this, null);
} catch (Exception e) {
android.util.Log.d("TestCase", "Error: Could not nullify field!");
}
if (field.get(this) != null) {
android.util.Log.d("TestCase", "Error: Could not nullify field!");
}
}
}
|
public void | setContext(android.content.Context context)
mContext = context;
|
protected void | setUp()
super.setUp();
|
protected void | tearDown()
super.tearDown();
|
public void | testAndroidTestCaseSetupProperly()
assertNotNull("Context is null. setContext should be called before tests are run",
mContext);
|