You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by bo...@apache.org on 2011/07/18 22:19:27 UTC
svn commit: r1148038 - in /buildr/trunk: CHANGELOG lib/buildr/java/tests.rb
spec/java/tests_spec.rb
Author: boisvert
Date: Mon Jul 18 20:19:24 2011
New Revision: 1148038
URL: http://svn.apache.org/viewvc?rev=1148038&view=rev
Log:
TestNG support for :groups and :excludegroups (Christopher Coco)
Modified:
buildr/trunk/CHANGELOG
buildr/trunk/lib/buildr/java/tests.rb
buildr/trunk/spec/java/tests_spec.rb
Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1148038&r1=1148037&r2=1148038&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Mon Jul 18 20:19:24 2011
@@ -1,9 +1,9 @@
1.4.7 (Pending)
+* Added: BUILDR-598 TestNG support for :groups and :excludegroups (Christopher Coco)
* Fixed: BUILDR-439 "The command line is too long" when running TestNG tests (Tammo Van Lessen)
* Fixed: BUILDR-595 Add option to specifiy location of ca cert
* Fixed: BUILDR-596 Update installation notes to talk about the all-in-one bundle
-
1.4.6 (2011-06-21)
* Added: BUILDR-592 Allow Users to Specify SSH Options for Deployment (Marc-André Laverdière)
* Fixed: BUILDR-591 Sort modules in iml files generated by idea task to ensure
Modified: buildr/trunk/lib/buildr/java/tests.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/tests.rb?rev=1148038&r1=1148037&r2=1148038&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/tests.rb (original)
+++ buildr/trunk/lib/buildr/java/tests.rb Mon Jul 18 20:19:24 2011
@@ -1,3 +1,4 @@
+
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with this
# work for additional information regarding copyright ownership. The ASF
@@ -328,6 +329,14 @@ module Buildr
def run(tests, dependencies) #:nodoc:
cmd_args = ['-log', '2', '-sourcedir', task.compile.sources.join(';'), '-suitename', task.project.id ]
cmd_args << '-d' << task.report_to.to_s
+ exclude_args = options[:excludegroups] || []
+ if !exclude_args.empty?
+ cmd_args << '-excludegroups' << exclude_args.join(",")
+ end
+ groups_args = options[:groups] || []
+ if !groups_args.empty?
+ cmd_args << '-groups' << groups_args.join(",")
+ end
# run all tests in the same suite
cmd_args << '-testclass' << tests
Modified: buildr/trunk/spec/java/tests_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/java/tests_spec.rb?rev=1148038&r1=1148037&r2=1148038&view=diff
==============================================================================
--- buildr/trunk/spec/java/tests_spec.rb (original)
+++ buildr/trunk/spec/java/tests_spec.rb Mon Jul 18 20:19:24 2011
@@ -494,4 +494,44 @@ describe Buildr::TestNG do
define('foo') { test.using(:testng) }
lambda { project('foo').test.invoke }.should change { File.exist?('reports/testng/foo/index.html') }.to(true)
end
+
+ it 'should include classes using TestNG annotations marked with a specific group' do
+ write 'src/test/java/com/example/AnnotatedClass.java', <<-JAVA
+ package com.example;
+ @org.testng.annotations.Test(groups={"included"})
+ public class AnnotatedClass { }
+ JAVA
+ write 'src/test/java/com/example/AnnotatedMethod.java', <<-JAVA
+ package com.example;
+ public class AnnotatedMethod {
+ @org.testng.annotations.Test
+ public void annotated() {
+ org.testng.AssertJUnit.assertTrue(false);
+ }
+ }
+ JAVA
+ define('foo').test.using :testng, :groups=>['included']
+ lambda { project('foo').test.invoke }.should_not raise_error
+ end
+
+ it 'should exclude classes using TestNG annotations marked with a specific group' do
+ write 'src/test/java/com/example/AnnotatedClass.java', <<-JAVA
+ package com.example;
+ @org.testng.annotations.Test(groups={"excluded"})
+ public class AnnotatedClass {
+ public void annotated() {
+ org.testng.AssertJUnit.assertTrue(false);
+ }
+ }
+ JAVA
+ write 'src/test/java/com/example/AnnotatedMethod.java', <<-JAVA
+ package com.example;
+ public class AnnotatedMethod {
+ @org.testng.annotations.Test(groups={"included"})
+ public void annotated() {}
+ }
+ JAVA
+ define('foo').test.using :testng, :excludegroups=>['excluded']
+ lambda { project('foo').test.invoke }.should_not raise_error
+ end
end