@@ -0,0 +1,1099 @@
+package com.cky.learnandroiddetails;%0A%0Aimport android.app.Activity;%0Aimport android.os.SystemClock;%0Aimport android.test.ActivityInstrumentationTestCase2;%0Aimport android.widget.TextView;%0A%0Aimport com.cky.learnandroiddetails.UnitTestExample.TestUnitTestAct;%0A%0A/**%0A * %E4%BD%9C%E8%80%85%EF%BC%9Acky%0A * %E6%97%B6%E9%97%B4%EF%BC%9A2016/9/28 16:43%0A * %E6%8F%8F%E8%BF%B0%EF%BC%9A%0A */%0A%0Apublic class MyTest extends ActivityInstrumentationTestCase2%3CTestUnitTestAct%3E %7B%0A%0A    private Activity mActivity;%0A%0A    public MyTest() %7B%0A        super(TestUnitTestAct.class);%0A    %7D%0A%0A    @Override%0A    protected void setUp() throws Exception %7B%0A        super.setUp();%0A        mActivity = getActivity();%0A%0A    %7D%0A%0A    //%E8%BF%90%E8%A1%8C%E7%9A%84%E5%87%BD%E6%95%B0%E5%8D%B3%E5%8F%AF%E6%B5%8B%E8%AF%95%0A    public void testTextView() %7B%0A        try %7B%0A            runTestOnUiThread(new Runnable() %7B%0A                @Override%0A                public void run() %7B%0A%0A                    TextView textView = (TextView) mActivity.findViewById(R.id.text_view);%0A                    textView.setText(%22Hello World%22);%0A%0A                %7D%0A            %7D);%0A        %7D catch (Throwable throwable) %7B%0A            throwable.printStackTrace();%0A        %7D%0A%0A        SystemClock.sleep(400000000);%0A    %7D%0A%7D%0A

更新 【Android Test ActivityInstrumentationTestCase2】