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?

+3


source to share


1 answer


  • Install Android Emulator plugin

    . You need a virtual device to run your tests.
  • Install plugins Rake

    and RVM

    as described here . You need to ruby

    install in in jenkins

    order to run your tests with the calabash-android

    gem.
  • Build shell script

    in jenkins

    and install Bundler

    .
  • Add gemfile

    to the workspace and specify the required gems. In our case, we need a calabash-android

    gem:

    # A sample Gemfile
    source "https://rubygems.org"
    
    # gem "rails"
    gem "calabash-android", "0.5.12"
    
          

  • Run bundle install

    in jenkins

    with a shell script. It will install the calabash-android

    gem.

  • Run tests from the folder containing gemfile

    from step 4th . At this point, you should have Bundler

    and calabash-android

    installed in jenkins

    .

    bundle exec calabash-android run "PATH_TO_APK" ADB_DEVICE_ARG=${ANDROID_AVD_DEVICE}

    ${ANDROID_AVD_DEVICE}

    is the name of the emulator provided Android Emulator plugin

    .

  • You may need Cucumber reports plugin

    and Cucumber test results plugin

    .

Update: Screenshots from the jenkins

job and shell script.

  • Android emulator configuration for 1st stage

Emulator config

  • Ruby environment for 2nd stage

Ruby environment

  • Shell script for stage 6th

Shell script

  • Cucumber test reports for 7th stage


Cucumber test reports

  • Cucumber + calabash structure. calabash

    located in the root folder of the project Android

    .

Files structure

  • 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"

    .

cucumber.yml

  • .calabash_settings

    contains information about keystore

    used for signature .apk

    at build time. calabash

    it test_server

    requires the same keystore

    .

.calabash_settings

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

      

+7


source







All Articles