class Buildr::JUnit::Report

Used by the junit:report task. Access through JUnit#report if you want to set various options for that task, for example:

JUnit.report.frames = false

Attributes

frames[RW]

True (default) to produce a report using frames, false to produce a single-page report.

params[R]

Parameters passed to the Ant JUnitReport task.

style_dir[RW]

Directory for the report style (defaults to using the internal style).

target[RW]

Target directory for generated report.

Public Class Methods

new() click to toggle source
# File lib/buildr/java/tests.rb, line 140
def initialize
  @params = {}
  @frames = true
  @target = 'reports/junit'
end

Public Instance Methods

generate(projects, target?) click to toggle source

Generates a JUnit report for these projects (must run JUnit tests first) into the target directory. You can specify a target, or let it pick the default one from the target attribute.

# File lib/buildr/java/tests.rb, line 152
def generate(projects, target = @target.to_s)
  html_in = File.join(target, 'html')
  rm_rf html_in ; mkpath html_in

  Buildr.ant('junit-report') do |ant|
    ant.taskdef :name=>'junitreport', :classname=>'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
      :classpath=>Buildr.artifacts(JUnit.ant_taskdef).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
    ant.junitreport :todir=>target do
      projects.select { |project| project.test.framework == :junit }.
        map { |project| project.test.report_to.to_s }.select { |path| File.exist?(path) }.
        each { |path| ant.fileset(:dir=>path) { ant.include :name=>'TEST-*.xml' }  }
      options = { :format=>frames ? 'frames' : 'noframes' }
      options[:styledir] = style_dir if style_dir
      ant.report options.merge(:todir=>html_in) do
        params.each { |key, value| ant.param :name=>key, :expression=>value }
      end
    end
  end
end