- 编写测试类继承AndroidTestCase,并且把这个类独立放在test包底下。一般情况下,在这个类里面写方法,测试你的工具类的方法,给出输入得到输出,以Log的形式展现出来。
- 在AndroidManifest.xml加入单元测试配置。具体地,先在Application标签中加入
<uses-library android:name="android.test.runner"/>
再在Application标签外加入instrumentation标签<instrumentation android:targetPackage="com.phoobobo.robot" android:label="this is a test" android:name="android.test.InstrumentationTestRunner"> </instrumentation>
包名和label请设置为自己的包名和自己命名label。 - 运行测试。如果是用Eclipse就右键项目名,选择Run As Android JUnit Test.
android单元测试举例
猜你喜欢
转载自phoobobo.iteye.com/blog/2339479
今日推荐
周排行