【问题标题】:Rails upgrade: rake test does nothingRails 升级:rake 测试什么都不做
【发布时间】:2015-11-16 23:54:37
【问题描述】:

将我的 rails 应用升级到 4.2 后,我开始编写自动化测试。

我从做一些超级简单的事情开始:

class SimpleTest < ActionDispatch::IntegrationTest
  test 'Browse a page' do
    assert true
    get '/'
    assert_response :success
  end
end

但是当我:

▶ rake test
▶ bin/rake test

什么都没有发生。没有错误,没有阻塞,进程完成,什么都没有。

我错过了什么吗?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 testing


    【解决方案1】:

    我在测试开始时错过了require 'test_helper',其中包含:

    # /test/test_helper.rb
    ENV["RAILS_ENV"] ||= "test"
    require File.expand_path('../../config/environment', __FILE__)
    require 'rails/test_help'
    
    class ActiveSupport::TestCase
      ActiveRecord::Migration.check_pending!
    
      # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
      #
      # Note: You'll currently still have to declare fixtures explicitly in integration tests
      # -- they do not yet inherit this setting
      fixtures :all
    
      # Add more helper methods to be used by all tests here...
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-09
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-10
      • 2011-09-24
      相关资源
      最近更新 更多