我的rails应用程序有一个黄瓜测试套件,包含大约500个场景,它们之间有大约5000个步骤。
我已使用以下.travis.yml
设置我的github存储库以使用Travis-CI。
language: ruby
rvm:
- "1.9.2"
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec cucumber -f progress -r features features/cards/base_game
- bundle exec cucumber -f progress -r features features/cards/basic_cards
- bundle exec cucumber -f progress -r features features/cards/intrigue
- bundle exec cucumber -f progress -r features features/cards/seaside
- bundle exec cucumber -f progress -r features features/cards/prosperity
- bundle exec cucumber -f progress -r features features/cards/interactions
before_script:
- cp config/database.travis.yml config/database.yml
- psql -c 'create database dominion_test' -U postgres
如果我只是跑bundle exec cucumber
来运行所有案例,我已经将黄瓜执行分开,因为Travis正在抛出内存。
然而,我最近的推动产生了一个Travis任务,花了50多分钟来完成我的所有测试,因此被杀死了。我只是对那么多场景不合理,还是我可以做些什么来加快执行速度?
编辑:如果重要,我应该澄清我的方案不会测试GUI。他们正在测试纸牌游戏服务器的规则,所以他们直接调用模型方法。
答案 0 :(得分:5)
我在this page of Travis' docs进行了大量的Google搜索后找到了解决方案。
基本上,允许(推荐,甚至!)并行运行。使用以下.travis.yml
,我最终得到六个并发作业,其中没有一个占用超过15分钟,因此全部运行完成:
language: ruby
rvm:
- "1.9.2"
env:
- CARD_SET=base_game
- CARD_SET=basic_cards
- CARD_SET=intrigue
- CARD_SET=seaside
- CARD_SET=prosperity
- CARD_SET=interactions
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec cucumber -f progress -r features features/cards/$CARD_SET
before_script:
- cp config/database.travis.yml config/database.yml
- psql -c 'create database dominion_test' -U postgres