Calabash integration in jenkins android
I have developed a test using calabash-android. Everything works as it should. Now I want to run scripts in Jenkins.
1) What plugin should I install in Jenkins?
2) How do I run the test? I am currently using the command: calabash-android run, I haven't reached any other path.
3) What do I need to additionally install on the server?
source to share
- Install
Android Emulator plugin
. You need a virtual device to run your tests. - Install plugins
Rake
andRVM
as described here . You need toruby
install in injenkins
order to run your tests with thecalabash-android
gem. - Build
shell script
injenkins
and installBundler
. -
Add
gemfile
to the workspace and specify the required gems. In our case, we need acalabash-android
gem:# A sample Gemfile source "https://rubygems.org" # gem "rails" gem "calabash-android", "0.5.12"
-
Run
bundle install
injenkins
with a shell script. It will install thecalabash-android
gem. -
Run tests from the folder containing
gemfile
from step 4th . At this point, you should haveBundler
andcalabash-android
installed injenkins
.bundle exec calabash-android run "PATH_TO_APK" ADB_DEVICE_ARG=${ANDROID_AVD_DEVICE}
${ANDROID_AVD_DEVICE}
is the name of the emulator providedAndroid Emulator plugin
. -
You may need
Cucumber reports plugin
andCucumber test results plugin
.
Update: Screenshots from the jenkins
job and shell script.
- Android emulator configuration for 1st stage
- Ruby environment for 2nd stage
- Shell script for stage 6th
- Cucumber test reports for 7th stage
- Cucumber + calabash structure.
calabash
located in the root folder of the projectAndroid
.
-
Cucumber.yml
the file contains various options related to cucumber. Especially for the platform, certain functions are provided. And you can select the platform using the"-p android"
or parameter"-p ios"
.
-
.calabash_settings
contains information aboutkeystore
used for signature.apk
at build time.calabash
ittest_server
requires the samekeystore
.
run_android_features script:
cd ..
PARAMS="-p android"
while getopts ":rd:" OPTION; do
case $OPTION in
r)
PARAMS=$PARAMS" --format json -o cucumber.json"
;;
d)
PARAMS=$PARAMS" ADB_DEVICE_ARG=$OPTARG"
;;
[?]) echo "Usage: $0 [-r] [-d DEVICE_ID].\n -r: should create reports.\n DEVICE_ID: where to run tests."
exit 1;;
esac
done
# clear old files
rm -rf screenshot*
rm -rf test_servers
# resign apk
bundle exec calabash-android build "../app/build/outputs/apk/app-debug.apk"
# run tests
bundle exec calabash-android run "../app/build/outputs/apk/app-debug.apk" $PARAMS
source to share