黄瓜测试套件对Travis来说太慢了

Cho*_*ett 5 cucumber ruby-on-rails-3 travis-ci

我有一个黄瓜测试套件为我的Rails应用程序,包括大约500个场景,它们之间约5000步.

我已经设置了我的github存储库以使用Travis-CI,使用以下内容.travis.yml.

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
Run Code Online (Sandbox Code Playgroud)

如果我跑去bundle exec cucumber运行所有的情况,我已经将黄瓜执行分开,因为特拉维斯扔掉了内存.

然而,我最近的推动产生了一个Travis任务,花了50多分钟来完成我的所有测试,因此被杀死了.我只是对那么多场景不合理,还是我可以做些什么来加快执行速度?

编辑:如果重要,我应该澄清我的方案不测试GUI.他们正在测试纸牌游戏服务器的规则,因此他们直接调用模型方法.

Cho*_*ett 5

经过大量谷歌搜索,我在Travis的文档页面上找到了一个解决方案.

基本上,它允许(推荐,甚至!)并行运行.通过以下内容.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
Run Code Online (Sandbox Code Playgroud)