3

Ruby 1.8.7、ci_reporter 1.8.4、テストユニット 2.5.4、rake 10.0.3 をインストールしました。

私の testA.rb, testB.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バッチコマンドからこれを試します:for /r "E:\ExempleOfTests\" %%i in (*.rb) do ruby "%%i"

ExempleOfTests フォルダー内のすべての .rb ファイルを実行します。

そのため、rakefile をリファクタリングして、Windows バッチ コマンドを取り込もうとしています。

ここで私の新しい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) ...

誰かが私を助けることができますか?

4

1 に答える 1

2

次のように実行できます。

find path/to/test/folder -name '*_test.rb' | xargs -n1 -I{} bundle exec ruby -Itest {}

必要に応じて、それを rake タスクにラップします。

于 2014-09-05T08:26:20.457 に答える