Class: BuildMaster::JUnitAnt
- Inherits:
-
Object
- Object
- BuildMaster::JUnitAnt
- Defined in:
- lib/buildmaster/auto/junit_ant.rb
Overview
JUnit ANT invocation
Instance Attribute Summary collapse
-
#classpath ⇒ Object
readonly
Returns the value of attribute classpath.
-
#jvmargs ⇒ Object
readonly
Returns the value of attribute jvmargs.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
-
#test ⇒ Object
readonly
Returns the value of attribute test.
Instance Method Summary collapse
- #coverage_report ⇒ Object
- #for_test(name) ⇒ Object
- #for_tests(pattern) ⇒ Object
- #generate(buildfile = nil) ⇒ Object
-
#initialize(report, project = nil) ⇒ JUnitAnt
constructor
A new instance of JUnitAnt.
- #run(buildfile = nil) ⇒ Object
- #target_name ⇒ Object
- #test_report ⇒ Object
- #with_coverage(jar) ⇒ Object
Constructor Details
#initialize(report, project = nil) ⇒ JUnitAnt
Returns a new instance of JUnitAnt.
6 7 8 9 10 11 12 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 6 def initialize(report, project = nil) @report = report @classpath = Classpath.new @jvmargs = Array.new @coverage = NilCoverage.new @project = project end |
Instance Attribute Details
#classpath ⇒ Object (readonly)
Returns the value of attribute classpath.
4 5 6 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 4 def classpath @classpath end |
#jvmargs ⇒ Object (readonly)
Returns the value of attribute jvmargs.
4 5 6 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 4 def jvmargs @jvmargs end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
4 5 6 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 4 def project @project end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
4 5 6 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 4 def report @report end |
#test ⇒ Object (readonly)
Returns the value of attribute test.
4 5 6 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 4 def test @test end |
Instance Method Details
#coverage_report ⇒ Object
22 23 24 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 22 def coverage_report report.dir('coverage') end |
#for_test(name) ⇒ Object
26 27 28 29 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 26 def for_test(name) @test = JUnitAntTest.new(self, name) self end |
#for_tests(pattern) ⇒ Object
31 32 33 34 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 31 def for_tests(pattern) @test = JUnitAntBatchTest.new(self, pattern) self end |
#generate(buildfile = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 45 def generate(buildfile = nil) if (test.nil?) raise 'test is not specified for junit task' end buildfile = report.file('junit-ant.xml') unless buildfile classpath_id = 'refid' @coverage.modify_classpath(classpath) buildfile.write do |file| file.puts <<BUILD <!-- ANT file generated by buildmaste JUnitAnt --> <project name="junit-ant" default="junit-ant"> #{@coverage.task_def} #{classpath.to_ant(classpath_id)} <target name="#{target_name}"> #{@coverage.instrument_task} <junit printsummary="yes" fork="yes" forkmode="perBatch" errorproperty="error" failureproperty="failure" haltonerror="no" haltonfailure="no"> <formatter type="xml"/> #{@coverage.sysproperty}#{classpath_ref(classpath_id)}#{jvmarg_elements}#{test.to_ant} </junit> <junitreport todir="#{test_report}"> <fileset dir="#{test_report}"> <include name="TEST-*.xml"/> </fileset> <report todir="#{test_report}" format="frames"/> </junitreport> #{@coverage.report_task(coverage_report)} <fail message="test failed"> <condition> <or> <isset property="fail"/> <isset property="error"/> </or> </condition> </fail> </target> </project> BUILD end buildfile end |
#run(buildfile = nil) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 85 def run(buildfile = nil) buildfile = generate(buildfile) @coverage.clean_instrumented_files test_report.mkdirs coverage_report.mkdirs AntDriver.new(buildfile).target(target_name) end |
#target_name ⇒ Object
14 15 16 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 14 def target_name 'junit-ant' end |
#test_report ⇒ Object
18 19 20 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 18 def test_report report.dir('test') end |
#with_coverage(jar) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/buildmaster/auto/junit_ant.rb', line 36 def with_coverage(jar) if (jar.basename.include?('cobertura')) @coverage = CobertunaCoverage.new(jar, project) else raise "do not know how to set up coverage tasks for #{jar}" end self end |