Last Updated: February 25, 2016
· kadrei

parallel execute calabash-android tests

A simple commandline script to start a calabash-android script on all adb-connected android devices.

declare -a arr
let i=0
export ANDROID_HOME=<path to android sdk>
while read line #get devices list
if [ -n "$line" ] && [ "`echo $line | awk '{print $2}'`" == "device" ]
        device="`echo $line | awk '{print $1}'`"
        echo "Add $device"
        arr[i]="$device" # $ is optional
        let i=$i+1
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
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

12 Responses
Add your response

Great one. How can I do this in Windows ?

over 1 year ago ·

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)

over 1 year ago ·

Hi , I really liked the concept of this , but how do i excute this one .

over 1 year ago ·

simply run it in your shell :)

over 1 year ago ·

Any solution on this for executing this script on windows....I tried above but no success...

over 1 year ago ·

I get this: 2: declare: not found 3: let: not found 14: Syntax error: redirection unexpected

over 1 year ago ·

which os are you on?

it worked for me on (x)ubuntu 12

over 1 year ago ·

will this code work on MAC ?

over 1 year ago ·

i don't know, cause i don't have a mac. but you may try.

over 1 year ago · line 14: syntax error near unexpected token <' line 14:done < <(adb devices)'

i get this error.
can you help me on this

over 1 year ago ·

I did some work around this and created this gem

This works on osx. not yet tested on windows. please try it out and if you need any help please let me know

over 1 year ago ·

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


Android serial execution

over 1 year ago ·