我的Ruby-on-Rails应用程序中没有命令“ rails test”

时间:2018-08-24 07:45:48

标签: ruby-on-rails system-testing

我最近加入了一个Ruby-on-Rails应用程序团队,我尝试审核测试。没有测试,所以我决定在应用程序中实现它们。

查看周围的内容后,我发现没有命令可以运行可用的测试。我运行了以下命令:

 rails --tasks

在输出中,没有诸如rails testrails test:system之类的命令。令人惊讶的是,我可以成功运行命令rails test。但是命令rails test:system --trace失败,输出如下:

 rails aborted!
 Don't know how to build task 'test:system' (see --tasks)
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task_manager.rb:59:in `[]'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:159:in `invoke_task'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/command.rb:48:in `invoke'
 C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top (required)>'
 bin/rails:9:in `require'
 bin/rails:9:in `<main>'

我尝试在新创建的应用中运行该命令,并且可以看到可用的命令rails testrails test:system

rails --tasks

您知道为什么命令rails test:system失败吗?谢谢。

Ruby版本:2.3.3

Rails版本:5.2.0

编辑:

我正在使用MiniTest

1 个答案:

答案 0 :(得分:0)

要一次性运行所有规格:

dart:ui

要执行特定的测试文件,请执行以下操作:

rspec

rspec <path to the file> # rspec spec/controllers/mytest_spec.rb 用于格式化输出。

如果--format documentation抛出依赖项错误,则添加bundle exec