2012-10-16 55 views
1

如果test = true,我想從測試代碼中排除cobertura。如果test = true,我想從測試代碼中排除cobertura

現在我有在頂部所有我需要的statments:

require 'buildr/java/cobertura' 
require 'buildr/scala' 

然後每次構建運行我得到這個:

插入檢測用的Cobertura數據文件 Ç類:在/ usr /git_workspaces/reports/cobertura.ser

這意味着我的生產代碼中含有cobertura工具。

這是我的構建

compile.with CORE, SLF4J, LOG4J, WS_CLIENTS, JODA_TIME, 
      [omitted for brevity] 

compile.options.other = %w(-encoding UTF-8) 

cobertura.exclude '[omitted for brevity]' 

resources.filter.using *RESOURCES_FILTER 

test.using :junit 
# need this because of forking. It does not appear to use the environmental variables defined above. 
test.using :java_args => ["-XX:MaxPermSize=128M"] 
test.with JUNIT, SCALATEST, MOCKITO, POWERMOCK, HAMCREST, SPRING.test 

# Pakcage is below here but the code has already been instrumented... 

的下一個部分是compile.with編譯地方實際發生的地方嗎?所以我可以做一個測試然後添加cobertura?

回答

2

如果你不需要「buildr/java/cobertura」,那麼就沒有工具了。

我們 '解決' 這樣的(至少命令行參數必須包括 「的Cobertura」,否則類不是儀表)

ARGV.each do |a| 
    if (a.include?("cobertura")) 
    require "buildr/java/cobertura" 
    break 
    end 
end 

你能做到這一點

require_cb = ture 
ARGV.each do |a| 
    if (a.include?("test=yes")) 
    require_cb = false  
    break 
    end 
end 
require "buildr/java/cobertura" if require_cb 

心連心

相關問題