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!
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With