Android单元测试笔记

1.在AndroidManifest.xml配置文件的<application>标签中加入:
  <uses-library android:name="android.test.runner" />          
  <application>标签外面加入:     
  <uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />         
  <instrumentationandroid:name="android.test.InstrumentationTestRunner"          
   android:targetPackage=""com.test"android:label="Test for my app"/>

2.编写单元测试代码:必须继承自AndroidTestCase类      

public void testGetDaysofWeek() throws Exception{

  DemoServise servise = new DemoServise();
  int week = servise.getDaysofWeek();
  Assert.assertEquals(3, week);

 }

3.执行测试

 

posted @ 2012-06-03 12:59  andriod2012  阅读(162)  评论(0编辑  收藏  举报