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.执行测试

 

你可能感兴趣的:(exception,android,单元测试,测试,application)