简体   繁体   中英

Inexplicable error when running tests

I get this error when I try to run rake test:profile . The error is coming from test_homepage which is in this file:

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

I don't understand why running this test has anything to do with creating a bank. Can anyone explain what's going on?

Are you using fixtures? If so, double check to see that data in your fixtures aren't violating a uniqueness constraint on one (or more) of your database tables.

I've had this issue before when creating a table with a unique index:

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

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

By default, the fixture for this model would get generated with non-unique data for the name attribute.

I'd assume this is a fresh test suite and you haven't updated your fixtures/bank.yml file with real data and you may actually have an ID field in it too, maybe?

Without seeing that fixture it's all guess work, but take a look at that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM