????Android?????????????
???????????? ???????[ 2012/12/17 10:17:23 ] ????????
Android???????
???????????android??????????????????????????·????С?
????????? ??java???????????????JUnit?? ??????????android sdk (version 1.1)?????????stubbed methods/classes????о???????????????????JUnit?????????????????е????????????? ??JDK?????У?????java?????????JUnit?????Runner?????????Eclipse???????????Run Configuration????????JUnit???????????????Classpath?????Bootstrap Entries?е?Android Library???JRE?????????junit.jar??????????????ο???http://developer.android.com/guide/appendix/faq/troubleshooting.html#addjunit?? ??????????????????????????е?JUnit??????JDK???????????android??????????????Щ??android????????????????????????????????????????????????android api??
????????? ????Instrumentation. Android???????????????InstrumentationTestRunner????????JUnit????TestRunner?????á???????Instrumentation????????????ν???????????????????????????????(??Target Package????)????????κ?????Instrumentation?????????android.app.Instrumentation??
??????????????????????????????Instrumentation????????????
????Step 1.?????д????????activity:
package com.android.ut;
import android.app.Activity;
import android.os.Bundle;
public class AndroidUT extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public int add(int a?? int b)
{
return a + b;
}
}
????Step 2.
????????????д???????????????????add()?????????????????????£?????????????У??????test????????????????com.android.ut.test????????????????????class.???????£?
package com.android.ut.test;
import com.android.ut.AndroidUT;
import android.test.ActivityInstrumentationTestCase;
public class TestApp extends ActivityInstrumentationTestCase
public TestApp()
{
super("com.android.ut"?? AndroidUT.class);
}
public void testSum()
{
assertEquals(5?? getActivity().add(2?? 3));
}
}
????Step 3.?????????????Manifest?????
??????????????????????????????
?????????
????Step 4.????
???????????????????????AndroidUT??????????????????????
????adb shell am instrument -e class com.android.ut.test.TestApp -wcom.android.ut/android.test.InstrumentationTestRunner
?????????????????????????
android:versionCode="1"
android:versionName="1.0.0">
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11