我已经安装了Ruby 1.8.7, ci_reporter 1.8.4, test unit 2.5.4, rake 10.0.3。
我的甲壳。rb的。rb……testZ。rb:
require 'includeA.rb'
require 'includeB.rb'
require 'includeC.rb'
require 'includeD.rb'
Begin of the code...
... End of the code
我的rakefile:
require 'rake/testtask'
require 'rubygems'
gem 'ci_reporter'
gem 'test-unit'
require 'test/unit'
require 'ci/reporter/rake/test_unit'
task :default => [:test]
task :test do
sh "ruby -I E:/pathToIncludesA/" " -I E:/pathToIncludesB/" " -I E:/pathToIncludesC/" " -I E:/pathToIncludesD/" " E:/pathToTests/testA.rb"
sh "ruby -I E:/pathToIncludesA/" " -I E:/pathToIncludesB/" " -I E:/pathToIncludesC/" " -I E:/pathToIncludesD/" " E:/pathToTests/testB.rb"
...
sh "ruby -I E:/pathToIncludesA/" " -I E:/pathToIncludesB/" " -I E:/pathToIncludesC/" " -I E:/pathToIncludesD/" " E:/pathToTests/testZ.rb"
end
和我启动测试执行:
rake CI_REPORTER=reports test
一切都很好,但现在很多测试将被添加到我的"pathToTest"中,现在我想运行所有的测试,但在我的rakefile中使用一个cmd。
我尝试从windows批处理cmd: for /r "E:ExempleOfTests" %%i in (*.rb) do ruby "%%i"
它运行了文件夹中所有的.rb文件。
所以现在我正在重构我的rakefile,试图合并windows批处理cmd.
这里是我的新rakefile:
require 'rake/testtask'
require 'rubygems'
gem 'ci_reporter'
gem 'test-unit'
require 'test/unit'
require 'ci/reporter/rake/test_unit'
task :default => [:test]
task :test do
sh "for /r E:/pathToTests/ %%i in (*.rb) do ruby -I E:/pathToIncludesA/ -I E:/pathToIncludesB/ -I E:/pathToIncludesC/ -I E:/pathToIncludesD/ %%i"
end
但是当我启动"rake CI_REPORTS=reports test"时,我的输出控制台:
unexpected %%i
rake aborted
commande failed with status (1) ...
有人能帮帮我吗?
可以这样运行:
find path/to/test/folder -name '*_test.rb' | xargs -n1 -I{} bundle exec ruby -Itest {}