【AT】Calabash-ios学习

项目中应用到了Calabash,于是根据官网的步骤试验了一番,也惊艳了一把。

原文地址:

https://github.com/calabash/calabash-ios

http://blog.lesspainful.com/2013/03/15/Testing-Multiple-Android-Apps/


【环境配置】

0. 安装有Ruby, 通过命令:ruby -v 查看;

1. 进入IOS工程所在目录; cd <your project>

2. 安装calabash-cucumber, 需要用sudo,否则可能会没有文件权限

sudo  gem install calabash-cucumber

终端结果:

1 gem installed
Installing ri documentation for calabash-cucumber-0.9.146...
Installing RDoc documentation for calabash-cucumber-0.9.146...


3.配置工程环境

运行命令:calabash-ios setup

或手工配置:查看主页下的Menual setup with Xcode;

[碰到的问题]

A. 自动配置完成后,一运行马上就应用程序crash

[解决]在XCode运行模拟器,启动应用程序之后,应该先退出应用程序;再在终端命令行执行:cucumber;这样会把

应用程序重新调起来; 

[注]在后来的测试中,又发现这并不是主要原因;在手工配置完成,可以run之后,命令行方式也可以work了


B. 手工配置的时候,根据主页的步骤完成,有24个编译错误。

[解决]忘记添加了CFNetwork.framework


4. 产生Feature文件

终端执行命令:calabash-ios gen

5. 在XCode中buildXXX-cal工程,启动模拟器,在程序运行后退出;

6. 在终端执行命令:cucumber


【文件解析】

my_first_step.rb:

Given /^I am on the Welcome Screen$/ do
  element_exists("view")
  check_element_exists("label text:'First View'")
  sleep(STEP_PAUSE)
end

这个语句,判定了当前条件"on the Welcome Screen"是否满足,如果element存在,则就在"Welcome Screen";


my_first.feature:

Feature: Running a test
  As an iOS developer
  I want to have a sample feature file
  So I can begin testing quickly

Scenario: Example steps1
  Given I am on the Welcome Screen
  Then I swipe left
  And I wait until I don't see "Please swipe left"
  And take picture

Scenario: Example steps2
  Given I am on the Welcome Screen
 #ASSERTION
  Then I should see a "login" button
 #INPUT TEXT
  Then I enter "my_username" into text field number 1
#  Then I touch "Return"

 #TOGGLE SWITCH
  Then I toggle the switch
  Then I touch "Login"
  And I touch "Second"
  And take picture

该文件描述了在“on the Welcome Screen”这个Step中需要做的事情,两个场景:steps1 和 steps2.

总的来说,my_first_step.rb,解释了Given的具体条件,而my_first.feature,则是描述在这个条件下需要

做什么事情;


【问题】

1. feature中的一些解释性的工作,是否都可以放在rb文件中呢?

2. feature中,一个Scenario就会使应用程序重新启动一次?


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值