Rails升级:rake测试什么都不做

时间:2015-11-16 23:54:37

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

将我的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

什么都没发生。没有错误,没有阻塞,流程结束,只是没有。

我错过了什么吗?

1 个答案:

答案 0 :(得分: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