Sunday 2 October 2016

How to Debug Code with Android Studio ?

Debugging your code to find out the flow of test case execution id very important for Mobile Automation Testing because if there is a test case execution error then we can find it easily and fix it quickly.

Android Studio  provides the shortcuts keys to debug your code and check for the root cause. Do try out below steps to debug your test case. Open any of your test case written in Android Studio.

1. Setting up debug pointer - Debug pointer means pin point a line of code from where you want to start debug mode and run your code one by one.left side of your code just perform a single click and then you will see a red dot which indicated the Debug Pointer.

2. Run Test Case in Debug Mode -  Right click on Test Class Name  -> Debug as ''Test Class Name'.

3. Debug Console -  As soon as you run the test code in Debug Mode, the code runs till the Debug Pointer and then at the bottom part of Android Studio a new window opens up which is called as Debug Console. It gives control in our hands now to run the code line by line.

4. Press the button highlighted in the below screenshot for recording the test code line by line. Each time you press the button the selected line of code will get executed.

5. If you got the error which you were looking for and now you want to run the entire set of code then press the button highlighted in the below window.

6. If you want to check out the variable value then open Variable Console and find out.

This is very simple and important thing to learn while writing Automation Code. Share with people who are working for Mobile Automation and spending more time on debugging test code. Happy Testing :)


  1. Thanks for the post,can u plz help me,the android development code and test case will be same project or different project.

  2. my appium test-case is running by run that single file,but my development code is not running.please help.