问题的标题几乎概括了它,但这里有一个更按时间顺序排列的描述:
- 我启动了一个新的 Rails 3.2.9 应用程序,没有通过任何特殊选项(即没有跳过测试单元)。
- 我将
minitest-rails
添加到 gemfile 并运行 bundle install。 - 我删除了测试文件夹的内容,然后运行
rails g mini_test:install
。
现在,如果我运行 rake test
,什么也不会发生。
我可以制作我自己的 rakefile 并手动指定 TestTask
,但我没有获得执行诸如 rake test:controllers
之类应该构建的操作的选项-除非我手动欺骗所有这些。
还有其他人遇到过这个吗?
最佳答案
确保在测试文件顶部添加 require 'test_helper'
。例如
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
test "should pass" do
assert true
end
end
我拥有的自动生成的 test_helper 文件如下所示:
ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
fixtures :all
end
关于ruby-on-rails - 安装 minitest rails 后,rake test 没有做任何事情,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13747045/