ruby-on-rails - 运行测试时出现莫名其妙的错误

标签 ruby-on-rails testing

我得到 this error当我尝试运行 rake test:profile 时。错误来自此文件中的 test_homepage:

require 'test_helper'
require 'rails/performance_test_help'

# Profiling results for each test method are written to tmp/performance.
class BrowsingTest < ActionDispatch::PerformanceTest
  def test_homepage
    get '/'
  end
end

我不明白为什么运行此测试与创建银行有任何关系。谁能解释一下这是怎么回事?

最佳答案

你在使用固定装置吗?如果是这样,请仔细检查您的设备中的数据是否违反了一个(或多个)数据库表的唯一性约束。

我以前在创建具有唯一索引的表时遇到过这个问题:

create_table "companies" do |t|
  t.string   "name"
  t.text     "description"
end

add_index "companies", "name", :unique => true

默认情况下,此模型的夹具将使用 name 属性的非唯一数据生成。

关于ruby-on-rails - 运行测试时出现莫名其妙的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4694423/

相关文章:

python - 在 python 中在哪里放置子包的测试?

javascript - 使用 Google 网站优化工具测试动态页面

javascript - HTML-选择以数组作为值的选项

html - 如何根据调用内容的页面更改 HAML 中的 css 元素?

ruby-on-rails - 急切加载 rails 库

ruby-on-rails - rails : link_to into another controller with params

python - django中的测试设置错误。 self 没有过去。

java - 确定 Maven 配置文件上的日期

ruby-on-rails - 哪个是目前最流行的 Ruby on Rails 授权 gem/插件?

testing - 如何设置 XUnit 测试的结果