Monday, May 3, 2010

How to add a test plan, package to Android CTS?

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 to avoid redundant name

$ cat $MYDROID/cts/tests/tests/MusicTests/
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

# We only want this apk build for tests.

LOCAL_JAVA_LIBRARIES := android.test.runner

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



include $(BUILD_PACKAGE)

Add one test case to CTS_CASE_LIST in build/core/tasks/

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

Add test plan 'MusicTests' in cts/tools/utils/

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

make cts again

$ . build/
$ 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]
Test summary: pass=13 fail=0 timeOut=0 notExecuted=0 Total=13
Time: 100.780s

Here is a video I run this MusicTestCases in Android emulator!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.