Author: assaf
Date: Tue Apr 22 00:12:05 2008
New Revision: 650394
URL: http://svn.apache.org/viewvc?rev=650394&view=rev
Log:
BUILDR-62: JUnit should be looking for @RunWith not @Test class annotation.
Fixed.
Modified:
incubator/buildr/trunk/doc/pages/testing.textile
incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb
incubator/buildr/trunk/spec/java_test_frameworks_spec.rb
Modified: incubator/buildr/trunk/doc/pages/testing.textile
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/doc/pages/testing.textile?rev=650394&r1=650393&r2=650394&view=diff
==============================================================================
--- incubator/buildr/trunk/doc/pages/testing.textile (original)
+++ incubator/buildr/trunk/doc/pages/testing.textile Tue Apr 22 00:12:05 2008
@@ -39,7 +39,8 @@
When you use JUnit, the dependencies includes JUnit, and Buildr picks up all
test classes from the project by looking for classes that either subclass
[EMAIL PROTECTED]@ or include methods annotated with @[EMAIL PROTECTED]
[EMAIL PROTECTED]@, include methods annotated with @org.junit.Test@,
+or test suites annotated with @[EMAIL PROTECTED]
The JUnit test framework supports the following options:
Modified: incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb?rev=650394&r1=650393&r2=650394&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb Tue Apr 22
00:12:05 2008
@@ -179,7 +179,7 @@
def tests(dependencies) #:nodoc:
filter_classes(dependencies,
:interfaces => %w{junit.framework.TestCase},
- :class_annotations => %w{org.junit.Test},
+ :class_annotations => %w{org.junit.runner.RunWith},
:method_annotations => %w{org.junit.Test})
end
Modified: incubator/buildr/trunk/spec/java_test_frameworks_spec.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/java_test_frameworks_spec.rb?rev=650394&r1=650393&r2=650394&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/java_test_frameworks_spec.rb (original)
+++ incubator/buildr/trunk/spec/java_test_frameworks_spec.rb Tue Apr 22
00:12:05 2008
@@ -77,6 +77,28 @@
project('foo').test.tests.should include('com.example.FirstTest')
end
+ it 'should include public classes with RunWith annotation' do
+ write 'src/test/java/com/example/TestSuite.java', <<-JAVA
+ package com.example;
+ import org.junit.Test;
+ public class TestSuite {
+ @Test
+ public void annotated() { }
+ }
+ JAVA
+ write 'src/test/java/com/example/RunSuite.java', <<-JAVA
+ package com.example;
+ import org.junit.runner.RunWith;
+ import org.junit.runners.Suite;
+ @RunWith(Suite.class)
+ @Suite.SuiteClasses({TestSuite.class})
+ public class RunSuite {
+ }
+ JAVA
+ define('foo').test.invoke
+ project('foo').test.tests.should include('com.example.RunSuite')
+ end
+
it 'should ignore classes not extending junit.framework.TestCase' do
write 'src/test/java/NotATest.java', <<-JAVA
public class NotATest { }