gpt4 book ai didi

ruby-on-rails - Rail3 rake 测试任务不运行测试

转载 作者:数据小太阳 更新时间:2023-10-29 07:23:24 27 4
gpt4 key购买 nike

我有一个与 Mr. Limpens 非常相似的问题,有一个主要不同:我确实将 test_unit railtie 包含到我的 application.rb 中。

来 self 的application.rb:

require File.expand_path('../boot', __FILE__)# Pick the frameworks you want:                                                                                                                                require 'action_controller/railtie'require 'dm-rails/railtie'# require 'action_mailer/railtie'                                                                                                                              # require 'active_resource/railtie'                                                                                                                            require 'rails/test_unit/railtie'# If you have a Gemfile, require the gems listed there, including any gems                                                                                     # you've limited to :test, :development, or :production.                                                                                                       Bundler.require(:default, Rails.env) if defined?(Bundler)

您会注意到我使用的是 DataMapper并使用 dm-rails 初始化我的项目 Bootstrap 。我可以像这样手动运行我的测试:

$ ruby -Itest test/unit/test_habit.rb Loaded suite test/unit/test_habitStarted.....Finished in 2.554523 seconds.5 tests, 7 assertions, 0 failures, 0 errors, 0 skipsTest run options: --seed 15947

但是当执行 rake 测试任务时,没有运行任何测试,如下所示:

$ rake test --trace(in /home/blt/Documents/projects/rails3apps/naughtyapp)** Invoke test (first_time)** Execute test** Invoke test:units (first_time)** Invoke test:prepare (first_time)** Execute test:prepare** Execute test:units** Invoke test:functionals (first_time)** Invoke test:prepare ** Execute test:functionals** Invoke test:integration (first_time)** Invoke test:prepare ** Execute test:integration

每次运行“first_time”都显示在括号中。我的测试没有运行,我必须做错什么?

最佳答案

我认为 rake 测试任务正在搜索匹配名称如 test/unit/**/*_test.rb 的测试文件。因此,您可能只需要将文件名 test_habit.rb 更改为 habit_test.rb。

关于ruby-on-rails - Rail3 rake 测试任务不运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4127177/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com