我已经使用 calabash-android 开发了一个测试。一切都按应有的方式运行。现在我想在 Jenkins 中运行这些场景。
1) 我应该在 Jenkins 中安装哪个插件?
2)如何运行我的测试?目前我正在使用命令:calabash-android run,我没有实现另一种方式。
3)我必须在服务器中额外安装什么?
我已经使用 calabash-android 开发了一个测试。一切都按应有的方式运行。现在我想在 Jenkins 中运行这些场景。
1) 我应该在 Jenkins 中安装哪个插件?
2)如何运行我的测试?目前我正在使用命令:calabash-android run,我没有实现另一种方式。
3)我必须在服务器中额外安装什么?
Android Emulator plugin. 您需要一个虚拟设备来运行您的测试。Rake和RVM插件。您需要安装才能使用gem 运行测试。rubyjenkinscalabash-androidshell script并jenkins安装Bundler.添加gemfile到您的工作区并指定所需的 gem。在我们的例子中,我们需要calabash-androidgem:
# A sample Gemfile
source "https://rubygems.org"
# gem "rails"
gem "calabash-android", "0.5.12"
使用 shell 脚本运行bundle install。jenkins它将安装calabash-androidgem。
gemfile从包含第 4步的文件夹运行您的测试。此时您应该已经安装bundler并calabash-android安装在jenkins.
bundle exec calabash-android run "PATH_TO_APK" ADB_DEVICE_ARG=${ANDROID_AVD_DEVICE}
${ANDROID_AVD_DEVICE}- 模拟器名称,由. 提供Android Emulator plugin。
您可能还需要Cucumber reports pluginand Cucumber test results plugin。
更新:Jenkins作业和 shell 脚本的屏幕截图。




calabash文件夹位于Android项目的根文件夹中。
Cucumber.yml文件包含不同的黄瓜相关设置。特别是该平台有特定的功能。并且可以使用参数"-p android"或选择平台"-p ios"。
.calabash_settings包含有关在构建期间keystore用于.apk签名的信息。Calabash需要相同keystore的test_server签名。
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