Alwin-Lin / development-debug-androidTest

2 stars 0 forks source link

Intorduction

Android device CTS test is hard. Developing Android device test takes a long time. Here are some tools and instructions to accelerate Android device test development and debug.

Problems

  1. Cannot run CTS on Windows 10. Try this script
  2. No good IDE for CTS test module, and build CTS takes long time. Create an Android Studio project for a CTS test module, e.g. CtsSampleDeviceTestCases to develop build and debug.
  3. Some CTS tests have a short run time, makeing manualy atatching debugger impossible. We can manual run test and attatch debugger using command lines
  4. Difficult to explore edit and debug CTS Verifier source code. Solution: ctsVerifier Android Studio project

    Debug CTS test APK with Android Studio

  5. Debug with the APK directly.
  6. Create and debug the Android Studio project.
  7. Build and debug the Android Studio project.
  8. Manually run a test case to allow manually attatch debugger.

    Debug with the APK directly

    Android Studio allows debuging an APK without the building. Before you start, make sure you have Setup CTS to run.

Open Android Studio, File> Profile or debug APK. Pick an APK form the testcases folder, and let Android Studio do it's work. After that is done, go to the activity that you want to debug and click on the atatch java/kolin source

atatch java

After that is done, you should be able to set a breakpoint and debug the Java code like such.

Debug Java

Create and debug the Android Studio project

It is easier to develope and debug with Android Studio. CTS is open source, it is possible to do so. However, CTS uses a different build system. You can create Android Studio Build configuration file to develope and debug the test module.

Examples:

  1. CTS Verifier
  2. CtsCarTestCase

Here is what it looks like after it's built Image of source

Get CTS source

Here are links to downloading source files in this project. The following are all CTS 9.0_R11

To download, click tgz and unzip to your workspace

Side notes, branch and tags

The following is a visualisation of a project