您的位置:首页 > 运维架构 > Shell

Calabash 快速入门 (Android)

2016-03-18 18:35 393 查看

Calabash 快速入门 (Android)

概述

本篇包括以下内容:

环境:mac/android studio

目标:用Calabash实现一个简单app的自动化测试

测试用例:信用卡的长度为16位

实现过程:搭建环境,编写APK,写测试用例,运行

流程

安装Calabash沙箱

编写app

写测试脚本

在模拟器或者真机上运行测试脚本,以及上传到cloudtest.xamarin.coms上进行测试。

安装Calabash沙箱-[官方链接]

为什么安装沙箱?

To get up and running as fast as possible to use Calabash, we recommend you use our Ruby Sandbox. The sandbox is a pre-configured ruby environment that has everything you need to start exploring Calabash and running tests right away. The sandbox is configured with the same version of Ruby running on Xamarin’s Test Cloud, so you don’t need to worry about ruby compatibilities.

如何安装?

curl -sSL https://raw.githubusercontent.com/calabash/install/master/install-osx.sh | bash

安装完成后,你会看到如下画面



安装成功后,在命令行执行calabash-sandbox进入沙箱模式

编写程序,生成APK-[官方链接]

程序源码下载:

下载地址1

下载地址2

打开源码:

用android studio打开源码,很重要的一点是添加上网权限

<uses-permission android:name="android.permission.INTERNET" />


创建一个签名,打一个带签名的包

写测试脚本[官方链接]

在沙箱模式下进入工程目录,在命令行中输入calabash-android gen



此时会发现工程目录下添加了一个features目录,my_first.feature即为我们的脚本文件



打开my_first.feature文件,改成如下内容:

Feature: Credit card validation.
Credit card numbers must be exactly 16 characters.

Scenario: Credit card number is too long
Given I wait for the "MainActivity" screen to appear
When I enter "99999999999999999" into input field number 1
And I press "validateButton"
Then I should see "Credit card number is too long."


运行脚本

重签APK

$ calabash-android resign

运行脚本

$ calabash-android run

运行过程



运行结果:



上传testcloud.xamarin.com进行测试请参见网站。

2016年3月18日记于此与君共勉。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: