Hi Android Experts,

I am very new to White box testing. And its really good and
Challenging to work on Unit Testing.

I need to know how to verify when an activity is launched .

I tried the following method :
public class MainActivityTest extends ActivityInstrumentationTestCase2
{

        private MainActivity mMainActivity;
        private Activity mActivity;
        private Instrumentation mInstrumentation;
        private Context mContext;
        private KeyguardManager mKeyGuardManager;
        private Lock mLock;

        public MainActivityTest()
        {
                super("com.android.mobilebackup.activity", MainActivity.class);
                // TODO Auto-generated constructor stub
        }

        @Override
        public void setUp()throws Exception
        {
                System.out.println("In SetUp Method");
                super.setUp();

                //Disables the Touch
                setActivityInitialTouchMode(false);

                //Makes sure that Key Lock is disabled
                /* mKeyGuardManager = (KeyguardManager)
getSystemService(KEYGUARD_SERVICE);
                 mLock = (Lock)
mKeyGuardManager.newKeyguardLock("activity_classname");
                ((KeyguardLock) mLock).disableKeyguard();*/

                //Initializes Instrumentation for test cases
                mInstrumentation = getInstrumentation();
                mActivity =getActivity();
                System.out.println("mActivity in setUp"+mActivity);


        }
        public void testPreconditions()
        {

        }

        //To test whether the targeted Activity is getting launched
        public void testLaunchActivity()throws Exception
        {

                System.out.println("mActivity in setUp"+mActivity);
                assertEquals("com.mobilebackup.activity.MainActivity", 
mActivity);

        }

When executed the above test application, the activity is getting
launched successfully. But the Test case fails becuse
of the following exception from the assert method.

04-14 16:04:05.183: INFO/TestRunner(8585):
junit.framework.AssertionFailedError:
expected:<com.android.mobilebackup.activity.MainActivity> but
was:<com.asurion.mobilebackup.activity.MainActivity@406812b8>

How do i make it work.??
Any kind of solution would be highly appretiated...

Thanks,
Shyam

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to