在jenkins安卓中集成葫芦

Alf*_*lus 3 android jenkins jenkins-plugins calabash-android

我用calabash-android开发了一个测试.一切都运行得如何.现在我想在Jenkins中运行场景.

1)我应该在Jenkins中安装哪个插件?

2)如何运行我的测试?目前我正在使用命令:calabash-android run,我没有实现另一种方式.

3)我必须在服务器中另外安装什么?

Vea*_*rji 8

  • 安装Android Emulator plugin.您需要一个虚拟设备来运行测试.
  • 安装RakeRVM所描述的插件在这里.您需要ruby安装jenkins才能使用calabash-androidgem 运行测试.
  • 创建shell scriptjenkins和安装Bundler.
  • 添加gemfile到您的工作区并指定所需的宝石.在我们的例子中我们需要calabash-androidgem:

    # A sample Gemfile
    source "https://rubygems.org"
    
    # gem "rails"
    gem "calabash-android", "0.5.12"
    
    Run Code Online (Sandbox Code Playgroud)
  • 运行bundle installjenkins使用shell脚本.它会安装calabash-android宝石.

  • 从包含文件夹中运行你的测试gemfile,从第4步.此时你应该安装bundlercalabash-android安装jenkins.

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

    ${ANDROID_AVD_DEVICE}- 模拟器名称,由Android Emulator plugin.提供.

  • 你可能也需要Cucumber reports pluginCucumber test results plugin.

更新:Jenkins作业和shell脚本的屏幕截图.

  • Android模拟器配置为第1

模拟器配置

  • 对于Ruby环境第2

Ruby环境

  • Shell脚本为第6

Shell脚本

  • 黄瓜测试报告第7

黄瓜测试报告

  • 黄瓜+葫芦项目结构.calabash文件夹位于Android项目的根文件夹中.

文件结构

  • Cucumber.yml文件包含不同的黄瓜相关设置.特别是平台有指定的功能.并且可以使用参数"-p android"或选择平台"-p ios".

cucumber.yml

  • .calabash_settings包含有关在构建期间keystore用于.apk签名的信息.签名Calabash需要相同keystore的内容test_server.

.calabash_settings

run_android_features脚本:

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
Run Code Online (Sandbox Code Playgroud)