0

我正在编写一个 rakefile,需要同时针对多个测试 dll 运行 mstest。我需要它只运行一次 mstest,因为我只需要一个 TRX 文件。为了针对多个测试 dll 运行 mstest,我需要能够/testcontainer:some.test.dll在同一命令中添加多个实例。这是我当前的 rake 任务:

task :tests do
    testDlls = FileList.new("#{BUILD_PATH}/*.Specs.dll")
sh "#{MSTEST_PATH} /testcontainer:#{testDlls}"      
end

例如,testDlls 有 test1.dll、test2.dll 和 test3.dll。上述任务输出:

c:\msbuild\msbuild.exe /testcontainer:test1.dll test2.dll test3.dll

我需要的是:

c:\msbuild\msbuild.exe /testcontainer:test1.dll /testcontainer:test2.dll /testcontainer:test3.dll

我怎样才能得到我想要的输出?

4

1 回答 1

2

那应该工作:

require 'shellwords'
task :tests do
    testDlls = FileList.new("#{BUILD_PATH}/*.Specs.dll")
    ary = Shellwords.shellwords(testDlls.to_s)
    sh "#{MSTEST_PATH} #{ary.map {|dll| '/testcontainer:' + dll}.join(' ')"      
end
于 2011-01-08T01:00:59.847 回答