How to add Android cts test cases 

Joined:
07/27/2010
Posts:
128

September 09, 2011 09:18:32    Last update: September 09, 2011 09:19:23
To add your own test cases to the Android cts suite:
  1. Copy the whole example directory:
    cd cts/tests/tests
    cp -R example mytests
    

  2. Change mytests/Android.mk to fit your needs:
    LOCAL_PATH:= $(call my-dir)
    
    include $(CLEAR_VARS)
    
    # Replace "Example" with your name.
    LOCAL_PACKAGE_NAME := CtsMyTestCases
    
    # Don't include this package in any target.
    LOCAL_MODULE_TAGS := optional
    
    # When built, explicitly put it in the data partition.
    LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
    
    # All tests should include android.test.runner.
    LOCAL_JAVA_LIBRARIES := android.test.runner
    
    LOCAL_SRC_FILES := $(call all-java-files-under, src)
    
    LOCAL_SDK_VERSION := current
    
    include $(BUILD_PACKAGE)
    

  3. Add the new tests to cts/CtsTestCaseList.mk:
    # These test cases will be analyzed by the CTS API coverage tools. 
    CTS_COVERAGE_TEST_CASE_LIST := \
    	CtsAccessibilityServiceTestCases \
    	CtsAccountManagerTestCases \
    	CtsAppTestCases \
    	CtsBluetoothTestCases \
    	CtsContentTestCases \
    	CtsDatabaseTestCases \
    	CtsDpiTestCases \
    	CtsDpiTestCases2 \
    	CtsExampleTestCases \
    	CtsMyTestCases \
            .
            .
            .
    

  4. Develop the tests as usual

If the test is not added to the CTS_COVERAGE_TEST_CASE_LIST, the build will only generate the xml file for the testcases, not the apk.
Share |
| Comment  | Tags