[英]Ruby on Rails - run unit tests in subfolder
Is it possible to run tests only from one subfolder? 是否可以仅从一个子文件夹运行测试?
Something like this: 像这样:
ruby -I"lib:test" test/functional/api/*
Thanks 谢谢
I assume you're trying to find a way to run multiple unit tests in a specific directory and you're not using RSpec... 我假设您正在尝试找到一种在特定目录中运行多个单元测试的方法,而您没有使用RSpec ...
In that case, you can create a task in a Rakefile and run it from command line. 在这种情况下,您可以在Rakefile中创建任务并从命令行运行它。 This page Rake::TestTask will tell you how to create such a file.
此页面Rake :: TestTask将告诉您如何创建这样的文件。 You're file is going to look something like this:
您的文件看起来像这样:
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/functional/api/*.rb']
t.verbose = true
end
And then run: 然后运行:
rake test
If you use rspec you can do this 如果使用rspec,则可以执行此操作
rspec ./spec/models/
for a folder 用于文件夹
and this 和这个
rspec ./spec/models/car_spec.rb
for one file 一个文件
and this 和这个
rspec ./spec/models/car_spec.rb:34
for the test on line 34 用于第34行的测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.