简体   繁体   English

rake中缺少测试任务:rake aborted! 不知道如何建立任务'测试:单位'

[英]Test tasks missing from rake: rake aborted! Don't know how to build task 'test:units'

I created a Rails 4 app recently and for some reason my rake tasks don't include test . 我最近创建了一个Rails 4应用程序,由于某些原因,我的rake任务不包括test Here's some console action to demonstrate the problem: 这是一些用于演示问题的控制台操作:

> rake test:units
    rake aborted!
    Don't know how to build task 'test:units'
    /Users/clozach/.rvm/gems/ruby-2.1.3@hoverfly/bin/ruby_executable_hooks:15:in `eval'
    /Users/clozach/.rvm/gems/ruby-2.1.3@hoverfly/bin/ruby_executable_hooks:15:in `<main>'
    (See full trace by running task with --trace)

Fail. 失败。 :( :(

> rake test
>

No output. 没有输出。 :( :(

> rake -T --all | grep test
    rake db:test:clone                      # 
    rake db:test:clone_schema               # 
    rake db:test:clone_structure            # 
    rake db:test:deprecated                 # 
    rake db:test:load                       # 
    rake db:test:load_schema                # 
    rake db:test:load_structure             # 
    rake db:test:prepare                    # 
    rake db:test:purge                      # 
    rake log:clear                          # Truncates all *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)
    rake tmp/cache/assets/test              # 

No test tasks at all! 完全没有test任务! :'( :'(

Any idea why this is the case, and what I can do to fix it? 知道为什么会这样,我能做些什么来解决它?

Take a look into config/application.rb whether the testing framework is actually required there. 看看config/application.rb是否确实需要测试框架。 At the very top, there should be 在最顶端,应该有

require "rails/all"

Depending on your setup, you might have each individual component required separately. 根据您的设置,您可能需要单独使用每个单独的组件。 Make sure that test_unit is among them. 确保test_unit就在其中。

require "rails/test_unit/railtie" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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