Return-Path: Delivered-To: apmail-maven-surefire-commits-archive@www.apache.org Received: (qmail 30264 invoked from network); 12 Jan 2011 20:13:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Jan 2011 20:13:21 -0000 Received: (qmail 1998 invoked by uid 500); 12 Jan 2011 20:13:21 -0000 Delivered-To: apmail-maven-surefire-commits-archive@maven.apache.org Received: (qmail 1958 invoked by uid 500); 12 Jan 2011 20:13:20 -0000 Mailing-List: contact surefire-commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: surefire-dev@maven.apache.org Delivered-To: mailing list surefire-commits@maven.apache.org Received: (qmail 1946 invoked by uid 99); 12 Jan 2011 20:13:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jan 2011 20:13:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jan 2011 20:13:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D3D082388865; Wed, 12 Jan 2011 20:12:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1058301 - in /maven/surefire/trunk: maven-surefire-plugin/src/site/apt/ maven-surefire-plugin/src/site/apt/examples/ surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/ Date: Wed, 12 Jan 2011 20:12:50 -0000 To: surefire-commits@maven.apache.org From: krosenvold@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110112201250.D3D082388865@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: krosenvold Date: Wed Jan 12 20:12:50 2011 New Revision: 1058301 URL: http://svn.apache.org/viewvc?rev=1058301&view=rev Log: [SUREFIRE-498] Properly implement fixture support in pojo provider Patch by Christian Gruber, applied with modifications Added: maven/surefire/trunk/maven-surefire-plugin/src/site/apt/examples/pojo-test.apt (with props) Modified: maven/surefire/trunk/maven-surefire-plugin/src/site/apt/index.apt maven/surefire/trunk/maven-surefire-plugin/src/site/apt/usage.apt maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java Added: maven/surefire/trunk/maven-surefire-plugin/src/site/apt/examples/pojo-test.apt URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/site/apt/examples/pojo-test.apt?rev=1058301&view=auto ============================================================================== --- maven/surefire/trunk/maven-surefire-plugin/src/site/apt/examples/pojo-test.apt (added) +++ maven/surefire/trunk/maven-surefire-plugin/src/site/apt/examples/pojo-test.apt Wed Jan 12 20:12:50 2011 @@ -0,0 +1,30 @@ + ------ + Using POJO tests + ------ + Christian Gruber + ------ + May 2008 + ------ + +Defining a POJO Test + + POJO tests look very much like JUnit or TestNG tests, though they do not + require dependencies on these artifacts. A test class should be named + <<<**/*Test>>> and should contain <<>> methods which will each be + executed by surefire. + + Validating assertions can be done using the JDK 1.4 <<>> keyword. + Simultaneous test execution is not possible with POJO tests. + + Fixture can be setup before and after each <<>> method by implementing + a set-up and a tear-down method. These methods must match these signatures + to be recognized and executed before and after each test method. + ++---+ +public void setUp(); +public void tearDown(); ++---+ + + These fixture methods can also throw any exception and will still be valid. + + \ No newline at end of file Propchange: maven/surefire/trunk/maven-surefire-plugin/src/site/apt/examples/pojo-test.apt ------------------------------------------------------------------------------ svn:eol-style = native Modified: maven/surefire/trunk/maven-surefire-plugin/src/site/apt/index.apt URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/site/apt/index.apt?rev=1058301&r1=1058300&r2=1058301&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-plugin/src/site/apt/index.apt (original) +++ maven/surefire/trunk/maven-surefire-plugin/src/site/apt/index.apt Wed Jan 12 20:12:50 2011 @@ -79,6 +79,8 @@ Maven Surefire Plugin * {{{./examples/junit.html}Using JUnit}} + * {{{./examples/pojo-test.html}Using POJO Tests}} + * {{{./examples/skipping-test.html}Skipping Tests}} * {{{./examples/inclusion-exclusion.html}Inclusions and Exclusions of Tests}} @@ -93,4 +95,5 @@ Maven Surefire Plugin * {{{./examples/configuring-classpath.html}Configuring the Classpath}} + * {{{./examples/providers.html}Selecting providers}} Modified: maven/surefire/trunk/maven-surefire-plugin/src/site/apt/usage.apt URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/site/apt/usage.apt?rev=1058301&r1=1058300&r2=1058301&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-plugin/src/site/apt/usage.apt (original) +++ maven/surefire/trunk/maven-surefire-plugin/src/site/apt/usage.apt Wed Jan 12 20:12:50 2011 @@ -61,6 +61,7 @@ mvn test public in the class, but the API dependency is not required. To perform assertions, the JDK 1.4 <<>> keyword can be used, or you can use <<>>. + See {{{examples/pojo-test.html} using POJO tests}} for more information. All of the providers support the Surefire Plugin parameter configurations. However, there are additional options available if you are running TestNG Modified: maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java?rev=1058301&r1=1058300&r2=1058301&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/PojoTestSet.java Wed Jan 12 20:12:50 2011 @@ -43,6 +43,10 @@ public class PojoTestSet private Object testObject; protected List testMethods; + + protected Method setUpMethod; + + protected Method tearDownMethod; private Class testClass; @@ -129,7 +133,7 @@ public class PojoTestSet { setUpFixture(); } - catch ( Exception e ) + catch ( Throwable e ) { report = new SimpleReportEntry( testObject.getClass().getName(), getTestName( userFriendlyMethodName ), new PojoStackTraceWriter( testObject.getClass().getName(), method.getName(), @@ -216,12 +220,14 @@ public class PojoTestSet return getTestClass().getName() + "." + testMethodName; } - public void setUpFixture() + public void setUpFixture() throws Throwable { + if (setUpMethod != null) setUpMethod.invoke( testObject, new Object[0] ); } - public void tearDownFixture() + public void tearDownFixture() throws Throwable { + if (tearDownMethod != null) tearDownMethod.invoke( testObject, new Object[0] ); } private void discoverTestMethods() @@ -252,6 +258,14 @@ public class PojoTestSet } } } + else if (m.getName().equals("setUp") && m.getParameterTypes().length == 0) + { + setUpMethod = m; + } + else if (m.getName().equals("tearDown") && m.getParameterTypes().length == 0) + { + tearDownMethod = m; + } } } }