gpt4 book ai didi

android - 在 jenkins android 中集成 Calabash

转载 作者:太空宇宙 更新时间:2023-11-03 12:07:14 24 4
gpt4 key购买 nike

我已经使用 calabash-android 开发了一个测试。一切都按应有的方式运行。现在我想在 Jenkins 中运行场景。

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

2) 如何运行测试?目前我使用的命令是: calabash-android run ,我没有实现其他方式。

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

最佳答案

  • 安装 Android Emulator plugin .您需要一个虚拟设备来运行您的测试。
  • 按照说明安装RakeRVM 插件here .您需要在 jenkins 中安装 ruby,以便使用 calabash-android gem 运行您的测试。
  • jenkins 中创建shell 脚本 并安装Bundler .
  • gemfile 添加到您的工作区并指定所需的 gem。在我们的例子中,我们需要 calabash-android gem:

    # A sample Gemfile
    source "https://rubygems.org"

    # gem "rails"
    gem "calabash-android", "0.5.12"
  • 使用 shell 脚本在 jenkins 中运行 bundle install。它将安装 calabash-android gem。

  • 从包含4th 步骤的gemfile 的文件夹运行您的测试。此时你应该在 jenkins 中安装了 bundlercalabash-android

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

    ${ANDROID_AVD_DEVICE} - 模拟器名称,由 Android 模拟器插件 提供。

  • 您可能还需要 Cucumber reports pluginCucumber test results plugin .

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

  • 第 1 步的 Android 模拟器配置

Emulator config

  • 第 2 步的 Ruby 环境

Ruby environment

  • 第 6 步的 Shell 脚本

Shell script

  • 第 7 步的 Cucumber 测试报告

Cucumber test reports

  • Cucumber + calabash 项目结构。 calabash 文件夹位于Android 项目的根文件夹中。

Files structure

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

cucumber.yml

  • .calabash_settings 包含有关在构建期间用于 .apk 签名的 keystore 的信息。 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

关于android - 在 jenkins android 中集成 Calabash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26482892/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com