我有一个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的类所在的位置吗?
发布于 2013-04-17 06:48:17
它告诉构建系统从哪里访问您要测试的实际项目。
这是必要的,因为您需要访问所有的活动和类,而不需要额外的副本。
有关它的信息分散在以下位置:http://developer.android.com/tools/testing/testing_android.html
发布于 2013-04-17 06:49:56
InstrumentationTestRunner是你用来编写安卓单元测试的东西。
从文档中:
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.https://stackoverflow.com/questions/16048492
复制相似问题