Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug instrumentation test

I have an issue in my instrumentation test (for which I use Robotium), so I decided to debug it. I usually run the test from command line with gradlew connectedAndroidTest, but it runs as well from Android Studio (v0.8.14) by selecting the specific gradle task. However if I try to debug that gradle task, I get an error Unable to open debugger port : java.net.SocketException "socket closed" and the test continues to run (without debugging). Is there another way to debug instrumentation test (with IDE) or I am missing something in my setup?

Update: However, it works on emulator!

enter image description here

like image 561
dragi Avatar asked Nov 03 '14 16:11

dragi


People also ask

What is an instrumentation test?

Instrumented tests are tests that run on physical devices and emulators, and they can take advantage of the Android framework APIs and supporting APIs, such as AndroidX Test.

How do you debug a test?

To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug. In Test Explorer, select the test method(s) and then choose Debug on the right-click menu.

What is the way to debug code in test suite?

Debug mode​ Open a test case and switch to the Script view. Double-click on the leftmost side of the script editor to mark a breakpoint. A breakpoint is where Katalon Studio pauses the test execution for you to start debugging. Choose a browser for Debug from the main toolbar.


1 Answers

I had the same problem. You're just running the tests in the wrong way. Instead of clicking "debug" on the gradle task "connectedAndroidTest" go to "Edit run configurations" in Android Studio. Click the "plus" sign and add a new "Android Tests" configuration. Then - select the module your tests reside in (probably the main module of your app) and save the configuration. Click "debug" on the newly created config.

like image 58
kosiara - Bartosz Kosarzycki Avatar answered Sep 22 '22 11:09

kosiara - Bartosz Kosarzycki