How to add a test plan, package to Android CTS? --Erin Yueh

  If we check Android source code, we can find some test packages in Android applications. We can either run these test packages in Android device or we can combine them with Android CTS from host machine. Here is an example from Music application. I will create a test plan MusicTests and test package MusicTestCases in CTS.

Add test package source code to cts folder


$ cp -a $MYDROID/packages/apps/Music/tests $MYDROID/cts/tests/tests/MusicTests



Modify test package name in Android.mk to avoid redundant name

$ cat $MYDROID/cts/tests/tests/MusicTests/Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# We only want this apk build for tests.
LOCAL_MODULE_TAGS := tests

LOCAL_JAVA_LIBRARIES := android.test.runner

# Include all test java files.
LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PACKAGE_NAME := MusicTestsCases

LOCAL_INSTRUMENTATION_FOR := Music

include $(BUILD_PACKAGE)



Add one test case to CTS_CASE_LIST in build/core/tasks/cts.mk

erin@midnight:~/eclair/build/core$ git diff
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index 917c5dc..17f6dbc 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -97,6 +97,7 @@ CTS_CASE_LIST := /
        CtsPerformance3TestCases /         CtsPerformance4TestCases /         CtsPerformance5TestCases / +       MusicTestsCases /
        ApiDemos /         ApiDemosReferenceTest /         $(CTS_CORE_CASE_LIST) /



Add test plan 'MusicTests' in cts/tools/utils/buildCts.py

  def GenerateTestPlans(self):
    .....
    plan = tools.TestPlan(packages)
    plan.Include(r'android/.MusicTests')
    self.__WritePlan(plan, 'MusicTests')



make cts again


$ cd $MYDROID
$ . build/envsetup.sh
$ make cts


run MusicTestCases

$ cd $mydroid/out/host/linux-x86/bin/
$ ./cts

cts_host > start --plan MusicTests
start test plan MusicTests
==============================================================
Test package: android.MusicTests
install met failure [install_failed_insufficient_storage]
com.android.music.tests.stress.AlbumsPlaybackStress#testAlbumPlay.....(pass)
com.android.music.tests.stress.AlbumsPlaybackStress#testActivityTestCaseSetUpProperly....(pass)
com.android.music.tests.stress.MusicPlaybackStress#testPlayAllSongs....(pass)
com.android.music.tests.stress.MusicPlaybackStress#testActivityTestCaseSetUpProperly....(pass)
com.android.music.tests.functional.TestPlaylist#testDeletePlaylist....(pass)
com.android.music.tests.functional.TestPlaylist#testRenamePlaylist....(pass)
com.android.music.tests.functional.TestPlaylist#testActivityTestCaseSetUpProperly....(pass)
com.android.music.tests.functional.TestSongs#testAddPlaylist.....(pass)
com.android.music.tests.functional.TestSongs#testSetRingtone.....(pass)
com.android.music.tests.functional.TestSongs#testDeleteSong.....(pass)
com.android.music.tests.functional.TestSongs#testActivityTestCaseSetUpProperly....(pass)
com.android.music.tests.MusicPlayerStability#testPlay30sMP3....(pass)
com.android.music.tests.MusicPlayerStability#testLaunchMusicPlayer....(pass)
==============================================================
Test summary: pass=13 fail=0 timeOut=0 notExecuted=0 Total=13
Time: 100.780s

 

 转自:http://i-miss-erin.blogspot.com/2010/05/how-to-add-test-plan-package-to-android.html 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值