lib/java/test.rb in buildr-0.20.0 vs lib/java/test.rb in buildr-0.21.0
- old
+ new
@@ -17,11 +17,11 @@
def initialize(*args) #:nodoc:
super
@classpath = []
@paths = []
- @include = []
+ @include = ["*Test", "*Suite"]
@exclude = []
enhance do |task|
unless test_cases.empty?
puts "Running tests in #{name}" if verbose
passed, failed = Java.junit(test_cases, :classpath=>classpath + @paths)
@@ -41,14 +41,13 @@
# test.include "com.example.FirstTest"
# test.include "com.example.*"
# test.include "com.example.Module*"
# test.include "*.{First,Second}Test"
#
- # If you do not specify any inclusion pattern explicitly, the default pattern is used.
- # This pattern picks up all classes with a name ending with Test (same as test.include "*Test").
- # Use the Test suffix to specify test case classes, and avoid the Test suffix for classes
- # that do not implement test cases (e.g. mock objects, helpers, etc).
+ # By default, all classes that have a name ending with Test or Suite are included.
+ # Use these suffixes for your test and test suite classes respectively, to distinguish them
+ # from stubs, helper classes, etc.
def include(*classes)
@include += classes
self
end
@@ -83,11 +82,10 @@
private
def test_cases()
unless @cases
- @include << "*Test" if @include.empty?
@cases = @paths.map do |path|
base = Pathname.new(path.to_s)
FileList["#{path}/**/*.class"].
map { |file| Pathname.new(file).relative_path_from(base).to_s.ext("").gsub(File::SEPARATOR, ".") }.
select { |name| @include.any? { |pattern| File.fnmatch(pattern, name) } }.
@@ -162,13 +160,13 @@
# junit() => JUnitTask
#
# Returns the JUnit task. This task executes JUnit test cases, from classes compiled by
# the test task.
#
- # By default it includes all classes with the suffix Test, and excludes all other classes.
- # Use the Test suffix for classes that implement test cases, avoid this suffix for other
- # classes (e.g. mocks, helper objects).
+ # By default it includes all classes with the suffix Test or Suite, and excludes all other classes.
+ # Use the Test/Suite suffix for classes that implement test cases, avoid this suffix for other
+ # classes (e.g. stubs, helper objects).
#
# You can also include only specific test cases, or exclude otherwise included test cases
# using #include and #exclude.
def junit()
@project.task("test:junit")
@@ -265,10 +263,10 @@
Java::TestTask.define_task("test")
project.test.instance_eval { instance_variable_set :@project, project }
project.recursive_task("test")
# Similar to the regular resources task but using different paths.
resources = Java::ResourcesTask.define_task("test:resources")
- project.path_to("src/test/resources").tap { |dir| resources.filter.include project.path_to(dir, "*") if File.exist?(dir) }
+ resources.filter.from project.path_to("src/test/resources")
# Similar to the regular compile task but using different paths.
compile = Java::CompileTask.define_task("test:compile"=>[project.compile, project.test.prepare, project.test.resources])
compile.enhance { project.test.resources.invoke }
project.path_to("src/test/java").tap { |dir| compile.from dir if File.exist?(dir) }
compile.into project.path_to("target/test-classes")