Class: Buildr::JUnitTask

Inherits:
Rake::Task
  • Object
show all
Defined in:
lib/java/test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ JUnitTask

Returns a new instance of JUnitTask.



9
10
11
12
13
14
15
16
17
18
# File 'lib/java/test.rb', line 9

def initialize(*args)
  super
  @classpath = []
  enhance do |task|
    test_cases.each do |test|
      Dir.chdir base_dir
      java "junit.textui.TestRunner", test, :classpath=>real_classpath, :name=>"tests in #{test}"
    end
  end
end

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



5
6
7
# File 'lib/java/test.rb', line 5

def base_dir
  @base_dir
end

#classpathObject

Returns the value of attribute classpath.



7
8
9
# File 'lib/java/test.rb', line 7

def classpath
  @classpath
end

#targetObject

Returns the value of attribute target.



6
7
8
# File 'lib/java/test.rb', line 6

def target
  @target
end

Instance Method Details

#real_classpathObject



28
29
30
# File 'lib/java/test.rb', line 28

def real_classpath()
  @real_classpath ||= artifacts(@classpath).map(&:to_s)
end

#test_casesObject



20
21
22
23
24
25
26
# File 'lib/java/test.rb', line 20

def test_cases()
  target = File.expand_path(self.target)
  return [] unless File.exist?(target)
  prefix = Regexp.new("^" + Regexp.escape(target) + "/")
  FileList[File.join(target, "**", "*Test.class")].
    map { |path| path.sub(prefix, "").ext("").gsub(File::SEPARATOR, ".") }.sort
end