roboguice.test
Class RoboActivityUnitTestCase<ActivityType extends android.app.Activity>

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by android.test.InstrumentationTestCase
              extended by android.test.ActivityTestCase
                  extended by android.test.ActivityUnitTestCase<ActivityType>
                      extended by roboguice.test.RoboActivityUnitTestCase<ActivityType>
All Implemented Interfaces:
junit.framework.Test

public class RoboActivityUnitTestCase<ActivityType extends android.app.Activity>
extends android.test.ActivityUnitTestCase<ActivityType>

A new instance of your activity is constructed for each test method in your RoboActivityUnitTestCase, so this is a great way to run many tests on an Activity in isolation. Note, however, that Activities instantiated by RoboActivityUnitTestCase won't be running in a "normal" system, it may not be appropriate for every kind of test case. See the ActivityUnitTestCase docs for specifics. Here's an example to get you started. public class MyActivityUnitTest extends ActivityUnitTestCase { protected Intent intent = new Intent(Intent.ACTION_MAIN); public MyActivityTest() { super(MyActivity.class); } // Make sure you use one of the @*Test annotations AND begin // your testcase's name with "test" \@MediumTest public void test01() { setApplication( new MyApplication( getInstrumentation().getTargetContext() ) ); final Activity activity = startActivity(intent, null, null); // Test some things assertNotNull(activity); assertEquals( ((TextView)activity.findViewById(R.id.hello)).getText(), "Hello World, Lop!"); } } Note that, as for RoboUnitTestCase, you'll need to add a constructor like the following to your Application class: public MyApplication( Context context ) { super(); attachBaseContext(context); }


Constructor Summary
RoboActivityUnitTestCase(Class<ActivityType> activityClass)
           
 
Method Summary
 
Methods inherited from class android.test.ActivityUnitTestCase
getActivity, getFinishedActivityRequest, getRequestedOrientation, getStartedActivityIntent, getStartedActivityRequest, isFinishCalled, setActivityContext, setApplication, setUp, startActivity, tearDown
 
Methods inherited from class android.test.ActivityTestCase
scrubClass, setActivity
 
Methods inherited from class android.test.InstrumentationTestCase
getInstrumentation, injectInsrumentation, injectInstrumentation, launchActivity, launchActivityWithIntent, runTest, runTestOnUiThread, sendKeys, sendKeys, sendRepeatedKeys
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RoboActivityUnitTestCase

public RoboActivityUnitTestCase(Class<ActivityType> activityClass)


Copyright © 2011. All Rights Reserved.