为什么水豚的功能规格在一起运行时会失败,仅限于我。但是单独通过?

时间:2015-11-02 16:40:39

标签: ruby-on-rails rspec capybara ui-testing gui-testing

这似乎是由于本地配置问题,但我尝试的任何内容都没有帮助,而且我被卡住了。

当我运行名为“user_save_quote”的rspec-capybara功能规范时,我得到了5/8的失败。但是,当我单独运行每个(失败的)行号时,它们会通过。此外,当其他开发人员完整地运行此规范时,每个测试都会通过它们。

我尝试过以下但没有一个帮助过:

  • 切换到firefox驱动程序
  • 删除我的.bashrc文件
  • 从Chrome中移除lastpass
  • 从非tmux会话运行规范
  • 使用和不使用bundle exec前缀
  • 运行
  • rake db:migraterake db:seedRAILS_ENV=test rake db:test:prepare
  • 关闭所有应用并重新启动计算机

应用程序中的可视行为是创建用户然后登录,但后续尝试执行这些操作似乎只挂了10秒然后失败。 我试过切换到firefox驱动程序,但它没有帮助。

1 个答案:

答案 0 :(得分:0)

尝试将此添加到规范助手中。

可能是因为用户已经创建了,并且对于下一个规范,您尝试再次创建

sequence

如果您使用它,请检查您的工厂,添加FactoryGirl.define do factory :user do |f| f.sequence(:name) { |n| "sir-#{n}-#{rand(99999)}" } f.sequence(:email) { |n| "sir#{n}#{rand(99999)}@example.com" } end

public UserDTO getUserById(int idUser) throws Exception {
    UserDTO resultado = null;
    try {
        UserDAO usuDAO = new UserDAO();
        resultado = new Mapper().Map(usuDAO.getUser(idUser));
    } catch (Exception e) {
        throw e;
    }

    return resultado;
}