-
Notifications
You must be signed in to change notification settings - Fork 41
Debugging TestServer.apk
Clone calabash-android and calabash-android-server within the same parent directory, for example:
mkdir ~/calabash
cd ~/calabash
git clone https://github.com/calabash/calabash-android-server
git clone https://github.com/calabash/calabash-android
- Launch Android Studio and choose Import project (Eclipse ADT, Gradle, etc.).
- Select the calabash-android-server, for example
~/calabash/calabash-android-server/server
. - Click Next a whole bunch of times until the project is opened.
- From the Run menu, select Edit Configurations.
- Click the + button and select Android Application.
- Set Name to TestServer.
- Select instrumentation-backend as the Module.
- Set Deploy to Nothing.
- Set Launch to Nothing.
- Remove Gradle-aware Make from Before launch:
- Click OK.
-
Navigate to the
ruby-gem
folder in the calabash-android repo, for example:cd ~/calabash/calabash-android/ruby-gem
-
Install the dependencies:
bundle install
-
Build the TestServer:
bundle exec rake build
TestServer.apk
will be generated in calabash-android/ruby-gem/lib/calabash-android/lib
.
If you later make any modifications to the source code then you just need to run bundle exec rake build
to generate a new TestServer.apk
.
-
Create a new directory to contain your apps/tests and copy the application to be tested into it, for example:
mkdir ~/calabash/myapp cp myapp.apk ~/calabash/myapp cd ~/calabash/myapp
-
Add a
Gemfile
which points at the calabash-android ruby gem source, for example:gem ‘calabash-android’, path:’~/calabash/calabash-android/ruby-gem’ source ‘https://rubygems.org’
-
Launch the calabash-android console for your test app, for example:
bundle exec calabash-android console myapp.apk
-
Install the app to test and the TestServer
reinstall_apps
- Enable developer mode.
- Open Settings -> Developer options.
- Enable USB debugging.
- Tap Select debug app and select your test app.
- If you need to debug loading processes: Enable Wait for debugger.
-
Force an update of the TestServer if you’ve modified the source code and rebuilt it:
bundle exec calabash-android build myapp.apk
-
Launch the calabash-android console for your test app, for example:
bundle exec calabash-android console myapp.apk
-
Shut down any running instances if required:
shutdown_test_server
-
Reinstall
TestServer.apk
reinstall_test_server
-
In the calabash-android console, launch the apps:
start_test_server_in_background
-
In Android Studio, select Run -> Attach debugger to Android process.
-
Tick Show all processes, select the app and click OK.
-
Set a breakpoint in Android Studio. For example, on the first line of the
executeQuery
method insh.calaba.instrumentationbackend.query.Query
which can be found in the file~/calabash/calabash-android-server/server/instrumentation-backend/src/sh.calaba/instrumentationbackend/query/Query.java
. -
In the calabash-android console, execute calabash commands to cause the breakpoint to be hit, for example:
query('button')