parallel execute calabash-android tests
A simple commandline script to start a calabash-android script on all adb-connected android devices.
#!/bin/bash
declare -a arr
let i=0
export ANDROID_HOME=<path to android sdk>
while read line #get devices list
do
if [ -n "$line" ] && [ "`echo $line | awk '{print $2}'`" == "device" ]
then
device="`echo $line | awk '{print $1}'`"
echo "Add $device"
arr[i]="$device" # $ is optional
let i=$i+1
fi
done < <(adb devices)
let port=34800 #starting port - can be a random port ( choosen by fair dice roll )
for deviceid in "${arr[@]}" #for each connected device start test on a specified port
do
mkdir $deviceid
#Set important variables for execution
ADB_DEVICE_ARG=$deviceid TEST_SERVER_PORT=$port SCREENSHOT_PATH=$deviceid/ calabash-android run <path to apk> --format html --out "$deviceid"_report.html & #Start test and do html report
port=$((port+1)) #increase port
done
Written by kadrei
Related protips
12 Responses
Great one. How can I do this in Windows ?
Sorry, I don't know the exact Code for Windows but you just need to do the same in windows.
1. get the device-ids
2. ADB_DEVICE_ARG=$deviceid TEST_SERVER_PORT=$port SCREENSHOT_PATH=$deviceid/ calabash-android run <path to apk> --format html --out "$deviceid"_report.html (should work on Windows too, just need to edit the variables)
Hi , I really liked the concept of this , but how do i excute this one .
simply run it in your shell :)
Any solution on this for executing this script on windows....I tried above but no success...
I get this:
testandroid.sh: 2: testandroid.sh: declare: not found
testandroid.sh: 3: testandroid.sh: let: not found
testandroid.sh: 14: testandroid.sh: Syntax error: redirection unexpected
which os are you on?
it worked for me on (x)ubuntu 12
will this code work on MAC ?
i don't know, cause i don't have a mac. but you may try.
parallel.sh: line 14: syntax error near unexpected token <'
parallel.sh: line 14:
done < <(adb devices)'
i get this error.
can you help me on this
I did some work around this and created this gem
https://rubygems.org/gems/parallel_calabash
https://github.com/rajdeepv/parallel_calabash
This works on osx. not yet tested on windows. please try it out and if you need any help please let me know
if target == 'android'
var =adb devices
#list of android devices
arr = var.lines #get in to lines
arr.shift && arr.pop #crop first and last lines
split with space and crop first
arr.each {|x| kid = x.split(" ").shift
mid = kid.lines #puts #{mis}
for i in mid
mkdir Android_#{i}
export ADB_DEVICE_ARG=#{i} SCREENSHOT_PATH=Android_#{i}/ APP=prebuilt/Android-debug.apk && bundle exec calabash-android run $APP -p android #{ARGV.join(' ')} --format html --out Android_#{i}/android_"#{i}".html --format pretty
end
}
Android serial execution