Android Test Framework
emulator -system system.img -data userdata.img -ramdisk ramdisk.img -verbose -show-kernel -sysdir . -kernel /android-sdk-linux_x86/platforms/android-10/images/kernel-qemu
emulator -system system.img -data userdata.img -ramdisk ramdisk.img -verbose -show-kernel -sysdir . -kernel /android-sdk-linux_x86/platforms/android-10/images/kernel-qemu -memory 256 -sdcard sd.img
export ANDROID_BUILD_TOP=/android-src
export ANDROID_PRODUCT_OUT=/android-src/out/target/product/generic
./development/testrunner/runtest.py –coverage imf
$ adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
$ adb -s emulator-5556 shell
# ls /system/framework
emma.jar
android.test.runner.jar
# am instrument -w com.android.imftest.tests/android.test.InstrumentationTestRunner
# am instrument -e coverage true -w com.android.imftest.tests/android.test.InstrumentationTestRunner
com.android.imftest.samples.BigEditTextActivityNonScrollablePanScanTests:.
com.android.imftest.samples.BigEditTextActivityNonScrollableResizeTests:.
com.android.imftest.samples.BigEditTextActivityScrollablePanScanTests:.
com.android.imftest.samples.BigEditTextActivityScrollableResizeTests:.
com.android.imftest.samples.BottomEditTextActivityPanScanTests:.
com.android.imftest.samples.BottomEditTextActivityResizeTests:.
com.android.imftest.samples.ButtonActivityTest:.
com.android.imftest.samples.ManyEditTextActivityNoScrollPanScanTests:.
com.android.imftest.samples.ManyEditTextActivityScrollPanScanTests:.
com.android.imftest.samples.ManyEditTextActivityScrollResizeTests:.
com.android.imftest.samples.OneEditTextActivityNotSelectedTests:.
com.android.imftest.samples.OneEditTextActivitySelectedTests:.
Test results for InstrumentationTestRunner=…………
Time: 132.654
OK (12 tests)
Generated code coverage data to /data/data/com.android.imftest/files/coverage.ec
# ls -l /data/data/com.android.imftest/files/coverage.ec
-rw——- app_30 app_30 849 2011-11-09 12:26 coverage.ec
$ adb -s emulator-5556 shell am instrument -w com.android.imftest.tests/android.test.InstrumentationTestRunner
$ adb -s emulator-5556 shell am instrument -e coverage true -w com.android.imftest.tests/android.test.InstrumentationTestRunner
$ adb -s emulator-5556 remount
$ adb -s emulator-5556 push out/target/product/generic/system/framework/emma.jar /system/framework/
$ adb -s emulator-5556 pull /data/data/com.android.imftest/files/coverage.ec .
$ java -cp external/emma/lib/emma.jar emma report -r html -in coverage.ec -sp ./frameworks/base/tests/ImfTest -in out/target/common/obj/APPS/ImfTest_intermediates/coverage.em
$ adb -s emulator-5556 shell am instrument -e coverage true -w com.example.android.notepad.tests/android.test.InstrumentationTestRunner
$ adb pull /data/data/com.example.android.notepad/files/coverage.ec .
$ java -cp external/emma/lib/emma.jar emma report -r html -in coverage.ec -sp ./development/samples/NotePad/src -in out/target/common/obj/APPS/NotePad_intermediates/coverage.em
發表迴響