Android Manifest Instrumentation



我有一个android test project设置来测试我的android project。在android test project的舱单中,我有instrumentation的条目。它看起来像:

<instrumentation
    android:name="android.test.InstrumentationTestRunner"
    android:targetPackage="com.company.android" />

我很好奇这个条目的意义是什么,特别是android:targetPackage="com.company.android"的目的是什么。我问这个问题,是因为我重构了旧项目并将类放入不同的包中,所以我很好奇我需要将这个值更新为什么……它是否应该指向扩展android.app.Application的类所在的包?

它告诉构建系统在哪里访问您将要测试的实际项目。

这是必要的,因为你需要访问所有的活动和类,而不需要额外的副本。

关于它的信息分散在:http://developer.android.com/tools/testing/testing_android.html

InstrumentationTestRunner是用来编写Android单元测试的工具。

来自文档:

Typical Usage
Write TestCases that perform unit, functional, or performance tests against the classes in your package. 
Typically these are subclassed from:
ActivityInstrumentationTestCase2
ActivityUnitTestCase
AndroidTestCase
ApplicationTestCase
InstrumentationTestCase
ProviderTestCase
ServiceTestCase
SingleLaunchActivityTestCase
In an appropriate AndroidManifest.xml, define the this instrumentation with the appropriate android:targetPackage set.
Run the instrumentation using "adb shell am instrument -w", with no optional arguments, to run all tests (except performance tests).
Run the instrumentation using "adb shell am instrument -w", with the argument '-e func true' to run all functional tests. These are tests that derive from InstrumentationTestCase.
Run the instrumentation using "adb shell am instrument -w", with the argument '-e unit true' to run all unit tests. These are tests that do notderive from InstrumentationTestCase (and are not performance tests).
Run the instrumentation using "adb shell am instrument -w", with the argument '-e class' set to run an individual TestCase.

相关内容

  • 没有找到相关文章

最新更新