You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(80) |
Nov
(42) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(11) |
Feb
(50) |
Mar
(70) |
Apr
(102) |
May
(28) |
Jun
(45) |
Jul
(14) |
Aug
(75) |
Sep
(17) |
Oct
(15) |
Nov
(11) |
Dec
(4) |
2003 |
Jan
(16) |
Feb
(19) |
Mar
(21) |
Apr
(20) |
May
(29) |
Jun
(7) |
Jul
(5) |
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(3) |
2004 |
Jan
(5) |
Feb
(4) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(1) |
Jul
(7) |
Aug
(1) |
Sep
(6) |
Oct
(6) |
Nov
(1) |
Dec
(2) |
2005 |
Jan
(4) |
Feb
(4) |
Mar
(15) |
Apr
(1) |
May
|
Jun
(4) |
Jul
(6) |
Aug
(6) |
Sep
|
Oct
(4) |
Nov
(2) |
Dec
(4) |
2006 |
Jan
|
Feb
(91) |
Mar
(47) |
Apr
(7) |
May
(4) |
Jun
(9) |
Jul
(1) |
Aug
|
Sep
(5) |
Oct
(36) |
Nov
(95) |
Dec
(12) |
2007 |
Jan
(11) |
Feb
(31) |
Mar
(45) |
Apr
(11) |
May
(9) |
Jun
(1) |
Jul
(146) |
Aug
(15) |
Sep
|
Oct
(3) |
Nov
(6) |
Dec
(1) |
2008 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(2) |
Aug
(19) |
Sep
(1) |
Oct
(10) |
Nov
|
Dec
(8) |
2009 |
Jan
(3) |
Feb
(1) |
Mar
(4) |
Apr
(8) |
May
(5) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
(2) |
Oct
(13) |
Nov
(13) |
Dec
(4) |
2010 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(2) |
May
|
Jun
(1) |
Jul
(3) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
(1) |
Feb
(4) |
Mar
(3) |
Apr
(4) |
May
|
Jun
(12) |
Jul
(16) |
Aug
(4) |
Sep
(7) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
From: David S. <ds...@us...> - 2007-04-26 19:56:48
|
Update of /cvsroot/junit/junit/src/org/junit/tests In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1805/src/org/junit/tests Modified Files: SuiteMethodTest.java AllTests.java AssertionTest.java Added Files: AnnotatedDescriptionTest.java Log Message: [Junit-trackers] [ junit-Bugs-1684562 ] assertEquals throws NPE while comparing null elements Descriptions now have Annotations --- NEW FILE: AnnotatedDescriptionTest.java --- package org.junit.tests; import static org.junit.Assert.*; import java.lang.annotation.Annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.Description; import org.junit.runner.Request; public class AnnotatedDescriptionTest { @Retention(RetentionPolicy.RUNTIME) public @interface MyOwnAnnotation { } @MyOwnAnnotation public static class AnnotatedClass { @Test public void a() { } } @Test public void annotationsExistOnDescriptionsOfClasses() { assertTrue((describe(AnnotatedClass.class).getAnnotation( MyOwnAnnotation.class) != null)); } @Test public void getAnnotationsReturnsAllAnnotations() { assertEquals(1, describe(ValueAnnotatedClass.class).getAnnotations() .size()); } @Ignore public static class IgnoredClass { @Test public void a() { } } @Test public void annotationsExistOnDescriptionsOfIgnoredClass() { assertTrue((describe(IgnoredClass.class).getAnnotation(Ignore.class) != null)); } @Retention(RetentionPolicy.RUNTIME) public @interface ValuedAnnotation { String value(); } @ValuedAnnotation("hello") public static class ValueAnnotatedClass { @Test public void a() { } } @Test public void descriptionOfTestClassHasValuedAnnotation() { Description description= describe(ValueAnnotatedClass.class); assertEquals("hello", description.getAnnotation(ValuedAnnotation.class) .value()); } @Test public void characterizeCreatingMyOwnAnnotation() { Annotation annotation= new Ignore() { public String value() { return "message"; } public Class<? extends Annotation> annotationType() { return Ignore.class; } }; assertEquals(Ignore.class, annotation.annotationType()); } private Description describe(Class<?> testClass) { return Request.aClass(testClass).getRunner().getDescription(); } } Index: SuiteMethodTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/SuiteMethodTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SuiteMethodTest.java 6 Dec 2006 01:22:48 -0000 1.1 +++ SuiteMethodTest.java 26 Apr 2007 19:56:30 -0000 1.2 @@ -1,11 +1,15 @@ package org.junit.tests; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import junit.framework.JUnit4TestAdapter; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.Description; import org.junit.runner.JUnitCore; +import org.junit.runner.Request; +import org.junit.runner.Result; public class SuiteMethodTest { public static boolean wasRun; @@ -47,4 +51,23 @@ JUnitCore.runClasses(NewTest.class); assertTrue(wasRun); } + + + public static class CompatibilityTest { + @Ignore @Test + public void ignored() { + } + + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(CompatibilityTest.class); + } + } + + @Test public void descriptionAndRunNotificationsAreConsistent() { + Result result= JUnitCore.runClasses(CompatibilityTest.class); + assertEquals(0, result.getIgnoreCount()); + + Description description= Request.aClass(CompatibilityTest.class).getRunner().getDescription(); + assertEquals(0, description.getChildren().size()); + } } Index: AllTests.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/AllTests.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- AllTests.java 21 Feb 2007 18:24:10 -0000 1.10 +++ AllTests.java 26 Apr 2007 19:56:30 -0000 1.11 @@ -46,7 +46,8 @@ SuiteMethodTest.class, TestClassMethodsRunnerTest.class, IgnoreClassTest.class, - OldTestClassAdaptingListenerTest.class + OldTestClassAdaptingListenerTest.class, + AnnotatedDescriptionTest.class }) public class AllTests { public static Test suite() { Index: AssertionTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/AssertionTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- AssertionTest.java 8 Feb 2007 22:45:20 -0000 1.6 +++ AssertionTest.java 26 Apr 2007 19:56:30 -0000 1.7 @@ -193,6 +193,36 @@ assertEquals(1.0d, 1.0d, 0.0d); } + @Test(expected= AssertionError.class) public void notEqualsObjectWithNull() { + assertEquals(new Object(), null); + } + + @Test(expected= AssertionError.class) public void notEqualsNullWithObject() { + assertEquals(null, new Object()); + } + + @Test public void notEqualsObjectWithNullWithMessage() { + Object o = new Object(); + try { + assertEquals("message", null, o); + fail(); + } + catch(AssertionError e) { + assertEquals("message expected:<null> but was:<" + o.toString() + ">", e.getMessage()); + } + } + + @Test public void notEqualsNullWithObjectWithMessage() { + Object o = new Object(); + try { + assertEquals("message", o, null); + fail(); + } + catch(AssertionError e) { + assertEquals("message expected:<"+ o.toString() + "> but was:<null>", e.getMessage()); + } + } + @Test(expected= AssertionError.class) public void objectsNotEquals() { assertEquals(new Object(), new Object()); } |
From: David S. <ds...@us...> - 2007-04-26 19:56:48
|
Update of /cvsroot/junit/junit/src/junit/framework In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1805/src/junit/framework Modified Files: JUnit4TestAdapter.java Log Message: [Junit-trackers] [ junit-Bugs-1684562 ] assertEquals throws NPE while comparing null elements Descriptions now have Annotations Index: JUnit4TestAdapter.java =================================================================== RCS file: /cvsroot/junit/junit/src/junit/framework/JUnit4TestAdapter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- JUnit4TestAdapter.java 13 Dec 2006 02:10:51 -0000 1.2 +++ JUnit4TestAdapter.java 26 Apr 2007 19:56:31 -0000 1.3 @@ -2,6 +2,7 @@ import java.util.List; +import org.junit.Ignore; import org.junit.runner.Description; import org.junit.runner.Request; import org.junit.runner.Runner; @@ -43,7 +44,24 @@ } public Description getDescription() { - return fRunner.getDescription(); + Description description= fRunner.getDescription(); + return removeIgnored(description); + } + + private Description removeIgnored(Description description) { + if (isIgnored(description)) + return Description.EMPTY; + Description result = description.childlessCopy(); + for (Description each : description.getChildren()) { + Description child= removeIgnored(each); + if (! child.isEmpty()) + result.addChild(child); + } + return result; + } + + private boolean isIgnored(Description description) { + return description.getAnnotation(Ignore.class) != null; } @Override |
From: David S. <ds...@us...> - 2007-04-26 19:56:48
|
Update of /cvsroot/junit/junit/src/org/junit/internal/runners In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1805/src/org/junit/internal/runners Modified Files: JUnit4ClassRunner.java Log Message: [Junit-trackers] [ junit-Bugs-1684562 ] assertEquals throws NPE while comparing null elements Descriptions now have Annotations Index: JUnit4ClassRunner.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/internal/runners/JUnit4ClassRunner.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- JUnit4ClassRunner.java 20 Mar 2007 14:43:50 -0000 1.1 +++ JUnit4ClassRunner.java 26 Apr 2007 19:56:31 -0000 1.2 @@ -1,5 +1,6 @@ package org.junit.internal.runners; +import java.lang.annotation.Annotation; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collections; @@ -48,13 +49,17 @@ @Override public Description getDescription() { - Description spec= Description.createSuiteDescription(getName()); + Description spec= Description.createSuiteDescription(getName(), classAnnotations()); List<Method> testMethods= fTestMethods; for (Method method : testMethods) - spec.addChild(methodDescription(method)); + spec.addChild(methodDescription(method)); return spec; } + protected Annotation[] classAnnotations() { + return fTestClass.getJavaClass().getAnnotations(); + } + protected String getName() { return getTestClass().getName(); } @@ -86,7 +91,12 @@ } protected Description methodDescription(Method method) { - return Description.createTestDescription(getTestClass().getJavaClass(), testName(method)); + Description result= Description.createTestDescription(getTestClass().getJavaClass(), testName(method), testAnnotations(method)); + return result; + } + + protected Annotation[] testAnnotations(Method method) { + return method.getAnnotations(); } public void filter(Filter filter) throws NoTestsRemainException { |
From: Anu G. D. <anu...@pu...> - 2007-04-10 05:45:11
|
Dear Junit Contributors, I am really thankful to Free/Open Source Software development community for their overwhelming response to the survey on practices and problems of defect management in Free/Open Source Software projects. If you have not participated ealier, you may spend a few minutes now too. The Online Questionnaire is available at: http://anu.puchd.ac.in/phpESP/public/survey.php?name=FOSS_Defect_Survey I hope you have found all the questions interesting and thought-provoking. Your answers will be kept anonymous.The data thus collected will only be used for research purpose. The insights gained from the study can further help us to extract publicly accessible defect data and determine impact of defect management practices on software quality. The results of study will soon be communicated to you. Thank You With regards, Anu Gupta Senior Lecturer Department of Computer Science and Applications, Panjab University, Chandigarh. INDIA In case of any problem in accessing/using the above mentioned link please contact: E-mail: anu...@pu... anu...@gm... |
From: Anu G. D. <anu...@pu...> - 2007-04-04 05:19:05
|
Dear Junit Contributors, I seek help from designers, developers, testers,defect fixers,project managers or playing any other key role in Free/Open Source software development or maintenence in carrying out a study on practices and problems of defect management in various Free/Open Source Software projects. The insights gained from the study can further help us to extract publicly accessible defect data and determine impact of defect management practices on software quality. Please spend a few minutes of your precious time to fill up the Questionnaire. The most of the questions follow multiple choice formats and are quite easy to answer. To have the Online Questionnaire, please visit: http://anu.puchd.ac.in/phpESP/public/survey.php?name=FOSS_Defect_Survey (You can also copy and paste this link into your browser, and hit the 'Return' key.) I hope you will find all the questions interesting and thought-provoking. Your answers will be kept anonymous.The data thus collected will only be used for research purpose.It would be nice if you may further refer this mail to others actively engaged with Free/Open Source Software development. If you have any query or suggestions then feel free to contact. Thank You With regards, Anu Gupta Senior Lecturer Department of Computer Science and Applications, Panjab University, Chandigarh. INDIA In case of any problem in accessing/using the above mentioned link please contact: E-mail: anu...@pu... anu...@gm... |
From: David S. <sa...@mi...> - 2007-03-29 02:00:04
|
JUnit 4.3.1 fixes two regressions in 4.3: * A bug that caused a NullPointerException when comparing a null reference to a non-null reference in assertEquals. * The binary jar for 4.3 accidentally included the tests and sample code, which are now removed for a smaller download, but, as always, available from the full zip. If you've had problems with either issue, please update to version 4.3.1. Thanks, Team JUnit |
From: David S. <ds...@us...> - 2007-03-29 01:49:13
|
Update of /cvsroot/junit/junit/build/experimental-use-of-antunit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28581/build/experimental-use-of-antunit Modified Files: Tag: Version431 junit-remote.ant Log Message: Use junitbuild Index: junit-remote.ant =================================================================== RCS file: /cvsroot/junit/junit/build/experimental-use-of-antunit/junit-remote.ant,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -d -r1.1 -r1.1.2.1 --- junit-remote.ant 20 Mar 2007 14:12:23 -0000 1.1 +++ junit-remote.ant 29 Mar 2007 01:49:05 -0000 1.1.2.1 @@ -1,14 +1,10 @@ <project xmlns:au="antlib:org.apache.ant.antunit"> - <import file="macros.ant"/> - + <import file="macros.ant" /> + <target name="testCharacterize_Upload"> - <!-- TODO: DUP --> - <ant antfile="build.xml" target="clean" dir="${junitdir}"> - <property name="dist" value="${antdist}" /> - </ant> - <!-- Should work --> - <ant antfile="build.xml" target="upload.to.sourceforge" dir="${junitdir}"> - <property name="dist" value="${antdist}" /> - </ant> + <junitbuild target="clean" /> + + <!-- Should work without error --> + <junitbuild target="upload.to.sourceforge" /> </target> </project> \ No newline at end of file |
From: David S. <ds...@us...> - 2007-03-27 23:32:41
|
Update of /cvsroot/junit/junit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27118 Modified Files: Tag: Version431 build.xml Log Message: [Junit-trackers] [ junit-Bugs-1686931 ] JUnit 4.3 contains samples and tests in junit-4.3[-src].jar Index: build.xml =================================================================== RCS file: /cvsroot/junit/junit/build.xml,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -d -r1.25 -r1.25.2.1 --- build.xml 20 Mar 2007 14:12:23 -0000 1.25 +++ build.xml 27 Mar 2007 19:00:43 -0000 1.25.2.1 @@ -6,13 +6,14 @@ <property name="dist" value="junit${version}" /> <property name="versionfile" value="${src}/junit/runner/Version.java" /> <property name="zipfile" value="${dist}.zip" /> - <property name="testfiles" value="junit/samples/**, junit/tests/**" /> + <property name="testfiles" value="junit/samples/**, junit/tests/**, org/junit/samples/**, org/junit/tests/**" /> <property name="unjarred" value="**/*.jar, ${testfiles}, doc/**, README.html, .classpath, .project, cpl-v10.html" /> - <property name="jarfile" value="junit-${version}.jar" /> + <property name="binjar" value="junit-${version}.jar" /> + <property name="srcjar" value="junit-${version}-src.jar" /> <property name="javadocdir" value="${dist}/javadoc" /> <property name="javadoczip" value="${dist}-javadoc.zip" /> <property name="javadocpackages" value="org.junit, org.junit.runner, org.junit.runner.description, org.junit.runner.manipulation, org.junit.runner.notification, org.junit.runners" /> - + <target name="init"> <tstamp/> </target> @@ -27,6 +28,16 @@ /> </target> + <target name="clean"> + <delete dir="${dist}" quiet="true" /> + <delete file="${zipfile}" quiet="true"/> + <delete> + <fileset dir="${basedir}" includes="**/*.class" /> + </delete> + + <delete file="${javadoczip}" /> + </target> + <target name="build" depends="versiontag"> <mkdir dir="${bin}"/> <javac @@ -37,57 +48,26 @@ <compilerarg value="-Xlint:unchecked" /> </javac> </target> - - <target name="distributeTestsAndExamples"> - <copy todir="${dist}/${dir}"> - <fileset dir="${bin}/${dir}" includes="${testfiles}" /> - <fileset dir="${src}/${dir}" includes="${testfiles}" /> - </copy> - </target> - - <target name="populate-dist" depends="clean, build"> - <delete dir="${dist}" /> + + <target name="jars"> <mkdir dir="${dist}" /> <jar - jarfile="${dist}/junit-${version}-src.jar" + jarfile="${dist}/${srcjar}" basedir="${src}" excludes="${unjarred}, **/*.class" /> <jar - jarfile="${dist}/${jarfile}" + jarfile="${dist}/${binjar}" basedir="${bin}" excludes="${unjarred}, **/*.java, build.xml" /> - <antcall target="distributeTestsAndExamples"> - <param name="dir" value="." /> - </antcall> - <antcall target="distributeTestsAndExamples"> - <param name="dir" value="org" /> - </antcall> - - <antcall target="javadoc" /> - - <copy todir="${dist}/doc"> - <fileset dir="doc"/> - </copy> - <copy file="README.html" tofile="${dist}/README.html" /> - <copy file="cpl-v10.html" tofile="${dist}/cpl-v10.html" /> - </target> - - <target name="dist" depends="populate-dist"> - <java classname="org.junit.runner.JUnitCore" fork="yes" failonerror="true"> - <arg value="org.junit.tests.AllTests"/> - <classpath> - <pathelement location="${dist}" /> - <pathelement location="${dist}/${jarfile}" /> - </classpath> - </java> </target> - <target name="javadoczip"> - <delete file="${javadoczip}" /> - <antcall target="javadoc" /> - <zip basedir="${javadocdir}" file="${javadoczip}" /> + <target name="samples-and-tests"> + <copy todir="${dist}"> + <fileset dir="${bin}" includes="${testfiles}" /> + <fileset dir="${src}" includes="${testfiles}" /> + </copy> </target> <target name="javadoc"> @@ -103,18 +83,34 @@ /> </target> - <target name="zip" depends="dist"> - <zip zipfile="${zipfile}" basedir="." includes="${dist}/**" /> + <target name="javadoczip"> + <delete file="${javadoczip}" /> + <antcall target="javadoc" /> + <zip basedir="${javadocdir}" file="${javadoczip}" /> + </target> + + <target name="populate-dist" + depends="clean, build, jars, samples-and-tests, javadoc" + > + <copy todir="${dist}/doc"> + <fileset dir="doc"/> + </copy> + <copy file="README.html" tofile="${dist}/README.html" /> + <copy file="cpl-v10.html" tofile="${dist}/cpl-v10.html" /> </target> - <target name="clean"> - <delete dir="${dist}" quiet="true" /> - <delete file="${zipfile}" quiet="true"/> - <delete> - <fileset dir="${basedir}" includes="**/*.class" /> - </delete> + <target name="dist" depends="populate-dist"> + <java classname="org.junit.runner.JUnitCore" fork="yes" failonerror="true"> + <arg value="org.junit.tests.AllTests"/> + <classpath> + <pathelement location="${dist}" /> + <pathelement location="${dist}/${binjar}" /> + </classpath> + </java> + </target> - <delete file="${javadoczip}" /> + <target name="zip" depends="dist"> + <zip zipfile="${zipfile}" basedir="." includes="${dist}/**" /> </target> <target name="upload.to.sourceforge" depends="zip"> |
From: David S. <ds...@us...> - 2007-03-27 19:54:40
|
Update of /cvsroot/junit/junit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3762 Modified Files: Tag: Version431 build.xml Log Message: Update to 4.3.1 Index: build.xml =================================================================== RCS file: /cvsroot/junit/junit/build.xml,v retrieving revision 1.25.2.1 retrieving revision 1.25.2.2 diff -u -d -r1.25.2.1 -r1.25.2.2 --- build.xml 27 Mar 2007 19:00:43 -0000 1.25.2.1 +++ build.xml 27 Mar 2007 19:22:36 -0000 1.25.2.2 @@ -2,7 +2,7 @@ <property file="${user.home}/.junit.properties" /> <property name="src" value="src" /> <property name="bin" value="bin" /> - <property name="version" value="4.3" /> + <property name="version" value="4.3.1" /> <property name="dist" value="junit${version}" /> <property name="versionfile" value="${src}/junit/runner/Version.java" /> <property name="zipfile" value="${dist}.zip" /> |
From: David S. <ds...@us...> - 2007-03-27 19:38:57
|
Update of /cvsroot/junit/junit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9268 Modified Files: Tag: Version431 README.html Log Message: Brought docs up to date with 4.3.1 Index: README.html =================================================================== RCS file: /cvsroot/junit/junit/README.html,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -u -d -r1.19 -r1.19.2.1 --- README.html 7 Mar 2007 19:50:50 -0000 1.19 +++ README.html 27 Mar 2007 19:38:50 -0000 1.19.2.1 @@ -4,13 +4,13 @@ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="Author" content="Erich Gamma, Kent Beck, and David Saff"> - <title>JUnit 4.3</title> + <title>JUnit 4.3.1</title> </head> <body> <h1> <b><font color="#00CC00">J</font><font color="#FF0000">U</font><font color="#000000">nit -4.2</b></h1> +4.3.1</b></h1> <br>Brought to you by <a href="http://www.threeriversinstitute.org">Kent Beck</a>, Erich Gamma, and <a href="http://david.saff.net">David Saff</a>. @@ -19,7 +19,7 @@ <br>(see also <a href="http://www.junit.org">JUnit.org</a>) <hr WIDTH="100%"> -<br>7 March 2007 +<br>27 March 2007 <p>JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. <ul> @@ -42,6 +42,21 @@ </ul> <h2> +<a NAME="Summary of"></a>Summary of Changes in version 4.3.1</h2> +<p> +<ul> +<li>Bug fix: 4.3 introduced a +<a href="https://sourceforge.net/tracker/?func=detail&atid=115278&aid=1684562&group_id=15278">bug</a> +that caused a NullPointerException +when comparing a null reference to a non-null reference in <tt>assertEquals</tt>. +This has been fixed. +<li>Bug fix: The binary jar for 4.3 <a href="https://sourceforge.net/tracker/?func=detail&atid=115278&aid=1686931&group_id=15278">accidentally</a> included the tests and sample code, +which are now removed for a smaller download, but, as always, available from the +full zip. +</ul> +</p> + +<h2> <a NAME="Summary of"></a>Summary of Changes with version 4.3</h2> <p> <ul> @@ -115,13 +130,13 @@ </tr> <tr> -<td><tt>junit-4.3.jar</tt></td> +<td><tt>junit-4.3.1.jar</tt></td> <td>a jar file with the JUnit framework</td> </tr> <tr> -<td><tt>junit-4.3-src.jar</tt></td> +<td><tt>junit-4.3.1-src.jar</tt></td> <td>a jar file with the source code of the JUnit framework</td> </tr> @@ -162,20 +177,20 @@ Below are the installation steps for installing JUnit: <ol> <li> -unzip the junit4.3.zip file</li> +unzip the junit4.3.1.zip file</li> <li> -add<i> </i><b>junit-4.3.jar</b> to the CLASSPATH. For example: +add<i> </i><b>junit-4.3.1.jar</b> to the CLASSPATH. For example: <tt> set classpath=%classpath%;INSTALL_DIR\junit-4.2.jar;INSTALL_DIR</tt></li> <li> test the installation by running <tt>java org.junit.runner.JUnitCore org.junit.tests.AllTests.</tt></li> <br><b><font color="#FF0000">Notice</font></b>: that the tests are not -contained in the junit-4.3.jar but in the installation directory directly. +contained in the junit-4.3.1.jar but in the installation directory directly. Therefore make sure that the installation directory is on the class path </ol> -<b><font color="#FF0000">Important</font></b>: don't install junit-4.3.jar +<b><font color="#FF0000">Important</font></b>: don't install junit-4.3.1.jar into the extension directory of your JDK installation. If you do so the test class on the files system will not be found. <h2> |
From: David S. <ds...@us...> - 2007-03-27 19:00:55
|
Update of /cvsroot/junit/junit/build/experimental-use-of-antunit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27118/build/experimental-use-of-antunit Modified Files: Tag: Version431 macros.ant junit.properties junit-slow.ant junit.ant Log Message: [Junit-trackers] [ junit-Bugs-1686931 ] JUnit 4.3 contains samples and tests in junit-4.3[-src].jar Index: macros.ant =================================================================== RCS file: /cvsroot/junit/junit/build/experimental-use-of-antunit/macros.ant,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -d -r1.1 -r1.1.2.1 --- macros.ant 20 Mar 2007 14:12:23 -0000 1.1 +++ macros.ant 27 Mar 2007 19:00:43 -0000 1.1.2.1 @@ -22,6 +22,8 @@ /> <property name="javadoczip" value="${testjavadoczip}" /> <property name="javadocpackages" value="org.junit" /> + <property name="binjar" value="${test.jarfile}" /> + <property name="srcjar" value="${test.srcjarfile}" /> </ant> </sequential> </macrodef> Index: junit.properties =================================================================== RCS file: /cvsroot/junit/junit/build/experimental-use-of-antunit/junit.properties,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -d -r1.1 -r1.1.2.1 --- junit.properties 10 Mar 2007 07:10:32 -0000 1.1 +++ junit.properties 27 Mar 2007 19:00:43 -0000 1.1.2.1 @@ -3,4 +3,6 @@ antdistdir=${junitdir}/${antdist} testjavadoczip=new-england-javadoc.zip exttestjavadoczip=${junitdir}/${testjavadoczip} -tempdir=tempdir \ No newline at end of file +tempdir=tempdir +test.jarfile=junit-test.version.jar +test.srcjarfile=junit-test.version-src.jar \ No newline at end of file Index: junit-slow.ant =================================================================== RCS file: /cvsroot/junit/junit/build/experimental-use-of-antunit/junit-slow.ant,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- junit-slow.ant 20 Mar 2007 14:12:23 -0000 1.2 +++ junit-slow.ant 27 Mar 2007 19:00:43 -0000 1.2.2.1 @@ -1,12 +1,8 @@ <project xmlns:au="antlib:org.apache.ant.antunit"> <import file="macros.ant"/> - <target name="testTearDown"> - <mkdir dir="${antdistdir}"/> - <antcall target="tearDown" /> - <au:assertFileDoesntExist file="${antdistdir}" /> - </target> - + <!-- CHARACTERIZATION TESTS --> + <target name="testCharacterize_DistGeneratesJavadoc"> <ant antfile="build.xml" target="dist" dir="${junitdir}"> <property name="dist" value="${antdist}" /> @@ -23,4 +19,28 @@ <au:assertLogContains text="Time:" /> </target> + + <target name="testCharacterize_PopulateCopiesSamplesAndTests"> + <junitbuild target="populate-dist" /> + <au:assertFileExists file="${antdistdir}/junit/samples" /> + <au:assertFileExists file="${antdistdir}/junit/tests" /> + <au:assertFileExists file="${antdistdir}/org/junit/samples" /> + <au:assertFileExists file="${antdistdir}/org/junit/tests" /> + </target> + + <!-- DRIVING TESTS --> + + <target name="testPopulateDoesntRecursivelyInclude"> + <junitbuild target="populate-dist" /> + <au:assertFileDoesntExist file="${antdistdir}/${antdist}" /> + </target> + + <target name="testPopulateDoesntIncludeSamplesInJUnitJar"> + <junitbuild target="populate-dist" /> + <au:assertFalse> + <available classname="org.junit.tests.AllTests" + classpath="${binjarfile}" + /> + </au:assertFalse> + </target> </project> \ No newline at end of file Index: junit.ant =================================================================== RCS file: /cvsroot/junit/junit/build/experimental-use-of-antunit/junit.ant,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- junit.ant 20 Mar 2007 14:12:23 -0000 1.2 +++ junit.ant 27 Mar 2007 19:00:43 -0000 1.2.2.1 @@ -1,6 +1,11 @@ <project xmlns:au="antlib:org.apache.ant.antunit"> - <import file="macros.ant"/> + <import file="macros.ant" /> + <property name="binjarfile" value="${antdistdir}/${test.jarfile}" /> + <property name="srcjarfile" value="${antdistdir}/${test.srcjarfile}" /> + + <!-- MACROS --> + <macrodef name="sizeOfDir"> <attribute name="property.name" /> <sequential> @@ -26,6 +31,14 @@ </sequential> </macrodef> + <macrodef name="unzip.exttestjavadoczip"> + <sequential> + <unzip dest="${tempdir}" src="${exttestjavadoczip}" /> + </sequential> + </macrodef> + + <!-- TEST FIXTURE TESTS --> + <target name="testTearDown"> <mkdir dir="${antdistdir}" /> <mkdir dir="${tempdir}" /> @@ -38,23 +51,18 @@ <au:assertFileDoesntExist file="${exttestjavadoczip}" /> </target> - <target name="testCharacterize_JavadocGeneratesJavadoc"> - <junitbuild target="javadoc" /> - <au:assertFileExists file="${antdistdir}/ant-unit-java-docs" /> - </target> - - <target name="testJavaDocZip"> - <junitbuild target="javadoczip" /> - <au:assertFileExists file="${exttestjavadoczip}" /> - - <antcall target="unzip.exttestjavadoczip" /> - <au:assertFileExists file="${tempdir}/org" /> + <target name="testCharacterize_DirSizeChanges"> + <dirSizeChanges property.name="changed"> + <mkdir dir="${tempdir}" /> + <echo message="h" file="${tempdir}/whatever.txt" /> + </dirSizeChanges> + <au:assertPropertySet name="changed" /> </target> - + <target name="testUnzipOnlyCreatesDirectoryCleanedByTeardown"> <dirSizeChanges property.name="changed"> <junitbuild target="javadoczip" /> - <antcall target="unzip.exttestjavadoczip" /> + <unzip.exttestjavadoczip /> <antcall target="tearDown" /> </dirSizeChanges> <au:assertFalse> @@ -62,16 +70,38 @@ </au:assertFalse> </target> - <target name="testCharacterize_DirSizeChanges"> - <dirSizeChanges property.name="changed"> - <mkdir dir="${tempdir}" /> - <echo message="h" file="${tempdir}/whatever.txt" /> - </dirSizeChanges> - <au:assertPropertySet name="changed" /> + <!-- CHARACTERIZATION TESTS DURING REFACTORING --> + + <target name="testCharacterize_JavadocGeneratesJavadoc"> + <junitbuild target="javadoc" /> + <au:assertFileExists file="${antdistdir}/ant-unit-java-docs" /> </target> - <target name="unzip.exttestjavadoczip"> - <unzip dest="${tempdir}" src="${exttestjavadoczip}" /> + <target name="testCharacterize_PopulateGeneratesJUnitJar"> + <junitbuild target="populate-dist" /> + <au:assertFileExists file="${binjarfile}" /> + </target> + + <target name="testCharacterize_PopulateGeneratesSrcJar"> + <junitbuild target="populate-dist" /> + <au:assertFileExists file="${srcjarfile}" /> + </target> + + <target name="testCharacterize_PopulateCopiesSamplesAndTests"> + <junitbuild target="samples-and-tests" /> + <au:assertFileExists file="${antdistdir}/junit/samples" /> + <au:assertFileExists file="${antdistdir}/junit/tests" /> + <au:assertFileExists file="${antdistdir}/org/junit/samples" /> + <au:assertFileExists file="${antdistdir}/org/junit/tests" /> + </target> + + <!-- DRIVING TESTS --> + + <target name="testJavaDocZip"> + <junitbuild target="javadoczip" /> + <au:assertFileExists file="${exttestjavadoczip}" /> + <unzip.exttestjavadoczip /> + <au:assertFileExists file="${tempdir}/org" /> </target> <target name="testJavaDocZipDeletedOnClean"> @@ -79,4 +109,14 @@ <junitbuild target="clean" /> <au:assertFileDoesntExist file="${exttestjavadoczip}" /> </target> + + <!-- [Junit-trackers] [ junit-Bugs-1686931 ] JUnit 4.3 contains samples and tests in junit-4.3[-src].jar --> + <target name="testJarsDoesntIncludeSamplesInJUnitJar"> + <junitbuild target="jars" /> + <au:assertFalse> + <available classname="org.junit.tests.AllTests" + classpath="${binjarfile}" + /> + </au:assertFalse> + </target> </project> \ No newline at end of file |
From: David S. <ds...@us...> - 2007-03-23 23:04:44
|
Update of /cvsroot/junit/junit/src/org/junit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22827/src/org/junit Modified Files: Tag: Version431 Assert.java Log Message: [Junit-trackers] [ junit-Bugs-1684562 ] assertEquals throws NPE while comparing null elements Index: Assert.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/Assert.java,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -d -r1.5 -r1.5.2.1 --- Assert.java 8 Feb 2007 22:45:21 -0000 1.5 +++ Assert.java 23 Mar 2007 23:04:39 -0000 1.5.2.1 @@ -455,8 +455,8 @@ String formatted= ""; if (message != null && ! message.equals("")) formatted= message + " "; - String expectedString= expected.toString(); - String actualString= actual.toString(); + String expectedString= String.valueOf(expected); + String actualString= String.valueOf(actual); if (expectedString.equals(actualString)) return formatted + "expected: " + expected.getClass().getName() + "<" + expectedString + "> but was: " + actual.getClass().getName() + "<" + actualString + ">"; else |
From: David S. <ds...@us...> - 2007-03-23 23:04:44
|
Update of /cvsroot/junit/junit/src/org/junit/tests In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22827/src/org/junit/tests Modified Files: Tag: Version431 AssertionTest.java Log Message: [Junit-trackers] [ junit-Bugs-1684562 ] assertEquals throws NPE while comparing null elements Index: AssertionTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/AssertionTest.java,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -d -r1.6 -r1.6.2.1 --- AssertionTest.java 8 Feb 2007 22:45:20 -0000 1.6 +++ AssertionTest.java 23 Mar 2007 23:04:39 -0000 1.6.2.1 @@ -193,6 +193,36 @@ assertEquals(1.0d, 1.0d, 0.0d); } + @Test(expected= AssertionError.class) public void notEqualsObjectWithNull() { + assertEquals(new Object(), null); + } + + @Test(expected= AssertionError.class) public void notEqualsNullWithObject() { + assertEquals(null, new Object()); + } + + @Test public void notEqualsObjectWithNullWithMessage() { + Object o = new Object(); + try { + assertEquals("message", null, o); + fail(); + } + catch(AssertionError e) { + assertEquals("message expected:<null> but was:<" + o.toString() + ">", e.getMessage()); + } + } + + @Test public void notEqualsNullWithObjectWithMessage() { + Object o = new Object(); + try { + assertEquals("message", o, null); + fail(); + } + catch(AssertionError e) { + assertEquals("message expected:<"+ o.toString() + "> but was:<null>", e.getMessage()); + } + } + @Test(expected= AssertionError.class) public void objectsNotEquals() { assertEquals(new Object(), new Object()); } |
From: David S. <sa...@mi...> - 2007-03-22 19:11:32
|
All, The sourceforge tracker for junit (https://sourceforge.net/tracker/?group_id=15278) used to have four categories, Bugs, Feature Requests, Support Requests, and Patches. I've closed Patches and Support Requests, and moved all their items into the other categories. This is a useful simplification. Support Requests were almost never used, and having a separate Patches category could give the impression that we didn't value patches for bugs and feature requests that didn't already have them, while also obscuring which patches fixed bugs and which added new features. If you believe that any of the items were moved to the wrong categories, please comment there-upon. Thanks, David Saff |
From: David S. <ds...@us...> - 2007-03-22 17:48:04
|
Update of /cvsroot/junit/junit/src/org/junit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27494/src/org/junit Modified Files: Ignore.java Log Message: @Ignore javadoc Fix TestClass method visibility Update build.xml to produce snapshots Index: Ignore.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/Ignore.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Ignore.java 24 Jan 2007 16:32:59 -0000 1.2 +++ Ignore.java 22 Mar 2007 17:47:52 -0000 1.3 @@ -6,10 +6,11 @@ import java.lang.annotation.Target; /** - * <p>Sometimes you want to temporarily disable a test. Methods annotated with {@link org.junit.Test} - * that are also annotated with <code>@Ignore</code> will not be executed as tests. Native JUnit 4 test runners - * should report the number of ignored tests along with the number of tests that ran and the - * number of tests that failed.</p> + * <p>Sometimes you want to temporarily disable a test or a group of tests. Methods annotated with + * {@link org.junit.Test} that are also annotated with <code>@Ignore</code> will not be executed as tests. + * Also, you can annotate a class containing test methods with <code>@Ignore</code> and none of the containing + * tests will be executed. Native JUnit 4 test runners should report the number of ignored tests along with the + * number of tests that ran and the number of tests that failed.</p> * * For example: * <pre> @@ -19,6 +20,13 @@ * <pre> * @Ignore("not ready yet") @Test public void something() { ... * </pre> + * @Ignore can also be applied to the test class:<br/> + * <pre> + * @Ignore public class IgnoreMe { + * @Test public void test1() { ... } + * @Test public void test2() { ... } + * } + * </pre> * */ @Retention(RetentionPolicy.RUNTIME) |
From: David S. <ds...@us...> - 2007-03-22 17:47:59
|
Update of /cvsroot/junit/junit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27494 Modified Files: build.xml Log Message: @Ignore javadoc Fix TestClass method visibility Update build.xml to produce snapshots Index: build.xml =================================================================== RCS file: /cvsroot/junit/junit/build.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- build.xml 20 Mar 2007 14:12:23 -0000 1.25 +++ build.xml 22 Mar 2007 17:47:52 -0000 1.26 @@ -1,8 +1,10 @@ <project name="junit" default="dist" basedir="."> + <tstamp /> + <property file="${user.home}/.junit.properties" /> <property name="src" value="src" /> <property name="bin" value="bin" /> - <property name="version" value="4.3" /> + <property name="version" value="4.4-snapshot-${DSTAMP}-${TSTAMP}" /> <property name="dist" value="junit${version}" /> <property name="versionfile" value="${src}/junit/runner/Version.java" /> <property name="zipfile" value="${dist}.zip" /> |
From: David S. <ds...@us...> - 2007-03-22 17:47:58
|
Update of /cvsroot/junit/junit/src/org/junit/internal/runners In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27494/src/org/junit/internal/runners Modified Files: TestClass.java Log Message: @Ignore javadoc Fix TestClass method visibility Update build.xml to produce snapshots Index: TestClass.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/internal/runners/TestClass.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TestClass.java 20 Mar 2007 14:43:50 -0000 1.1 +++ TestClass.java 22 Mar 2007 17:47:52 -0000 1.2 @@ -23,11 +23,11 @@ return getAnnotatedMethods(Test.class); } - public List<Method> getBefores() { + List<Method> getBefores() { return getAnnotatedMethods(BeforeClass.class); } - public List<Method> getAfters() { + List<Method> getAfters() { return getAnnotatedMethods(AfterClass.class); } |
From: David S. <ds...@us...> - 2007-03-22 17:47:56
|
Update of /cvsroot/junit/junit/src/org/junit/runners In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27494/src/org/junit/runners Modified Files: package-info.java Log Message: @Ignore javadoc Fix TestClass method visibility Update build.xml to produce snapshots Index: package-info.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/runners/package-info.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- package-info.java 20 Mar 2007 14:43:50 -0000 1.2 +++ package-info.java 22 Mar 2007 17:47:52 -0000 1.3 @@ -3,6 +3,6 @@ * * @since 4.0 * @see org.junit.runner.Runner - * @see org.junit.internal.runners.TryToDoEverythingRunner + * @see org.junit.internal.runners.JUnit4ClassRunner */ package org.junit.runners; \ No newline at end of file |
From: David S. <sa...@mi...> - 2007-03-20 15:37:48
|
All, Development has begun on JUnit 4.4, which promises to be more revolutionary than the previous, more evolutionary, releases since 4.1. This release will likely contain several new features that we believe are ideal for all testers. The first changes, however, are in our support for custom runners. If you have ever written, or been tempted to write, a custom runner, read on. Otherwise, feel free to archive this mail away, wait here for further updates. :-) ... ... Are they gone? Good. By annotating a test class with @RunWith, a tester can declare to JUnit that a class should be interpreted in a vastly different way than usual. A great example is Johannes Link's ClasspathSuite runner ( http://johanneslink.net/cpsuite.html). However, if an extender of JUnit wanted a class to be interpreted in mostly the same way, but with a slight change (for example, the custom runner that ships with JMock 2), they are required to copy or inherit from internal classes like TestClassRunner. In 4.4, we will add API classes that will make this process easier. At the same time, the internal package will undergo significant changes, almost certainly breaking custom runners that have depended on these classes in the past. In order to ease this transition, we would like to involve each of you to get your feedback about what should change, and also to provide you with frequent feedback about what is changing. To that end, CVS HEAD has been updated with the latest work, and a 4.4-snapshots release category has been created on sourceforge for snapshot zips. You'll notice, for example, that TestClassRunner is already gone, replaced by JUnit4ClassRunner. Other changes are also afoot. For further discussion on this topic, please join the junitcomplements mailing list at http://tech.groups.yahoo.com/group/junitcomplements/ I look forward to seeing you there! David Saff |
From: David S. <ds...@us...> - 2007-03-20 14:43:59
|
Update of /cvsroot/junit/junit/src/org/junit/internal In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30152/src/org/junit/internal Added Files: TextListener.java Log Message: Runner rearchitecting to begin 4.4 development --- NEW FILE: TextListener.java --- package org.junit.internal; import java.io.PrintStream; import java.text.NumberFormat; import org.junit.runner.Description; import org.junit.runner.Result; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunListener; public class TextListener extends RunListener { private final PrintStream fWriter; public TextListener() { this(System.out); } public TextListener(PrintStream writer) { this.fWriter= writer; } @Override public void testRunFinished(Result result) { printHeader(result.getRunTime()); printFailures(result); printFooter(result); } @Override public void testStarted(Description description) { fWriter.append('.'); } @Override public void testFailure(Failure failure) { fWriter.append('E'); } @Override public void testIgnored(Description description) { fWriter.append('I'); } /* * Internal methods */ private PrintStream getWriter() { return fWriter; } protected void printHeader(long runTime) { getWriter().println(); getWriter().println("Time: " + elapsedTimeAsString(runTime)); } protected void printFailures(Result result) { if (result.getFailureCount() == 0) return; if (result.getFailureCount() == 1) getWriter().println("There was " + result.getFailureCount() + " failure:"); else getWriter().println("There were " + result.getFailureCount() + " failures:"); int i= 1; for (Failure each : result.getFailures()) printFailure(each, i++); } protected void printFailure(Failure failure, int count) { printFailureHeader(failure, count); printFailureTrace(failure); } protected void printFailureHeader(Failure failure, int count) { getWriter().println(count + ") " + failure.getTestHeader()); } protected void printFailureTrace(Failure failure) { getWriter().print(failure.getTrace()); } protected void printFooter(Result result) { if (result.wasSuccessful()) { getWriter().println(); getWriter().print("OK"); getWriter().println(" (" + result.getRunCount() + " test" + (result.getRunCount() == 1 ? "" : "s") + ")"); } else { getWriter().println(); getWriter().println("FAILURES!!!"); getWriter().println("Tests run: " + result.getRunCount() + ", Failures: " + result.getFailureCount()); } getWriter().println(); } /** * Returns the formatted string of the elapsed time. Duplicated from * BaseTestRunner. Fix it. */ protected String elapsedTimeAsString(long runTime) { return NumberFormat.getInstance().format((double) runTime / 1000); } } |
Update of /cvsroot/junit/junit/src/org/junit/tests In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30152/src/org/junit/tests Modified Files: ForwardCompatibilityTest.java OldTestClassRunnerTest.java InaccessibleBaseClassTest.java ParameterizedTestMethodTest.java InitializationErrorForwardCompatibilityTest.java SingleMethodTest.java SortableTest.java OldTestClassAdaptingListenerTest.java TextListenerTest.java AnnotationTest.java TestMethodTest.java UserStopTest.java ParameterizedTestTest.java ValidationTest.java Log Message: Runner rearchitecting to begin 4.4 development Index: ForwardCompatibilityTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/ForwardCompatibilityTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ForwardCompatibilityTest.java 21 Feb 2007 14:44:00 -0000 1.2 +++ ForwardCompatibilityTest.java 20 Mar 2007 14:43:49 -0000 1.3 @@ -169,6 +169,7 @@ public static class InvalidMethodTest { @BeforeClass public void shouldBeStatic() {} + @Test public void aTest() {} } public void testInvalidMethod() { Index: OldTestClassRunnerTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/OldTestClassRunnerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- OldTestClassRunnerTest.java 6 Dec 2006 01:22:48 -0000 1.2 +++ OldTestClassRunnerTest.java 20 Mar 2007 14:43:49 -0000 1.3 @@ -7,7 +7,7 @@ import junit.framework.TestSuite; import org.junit.Assert; import org.junit.Test; -import org.junit.internal.runners.OldTestClassRunner; +import org.junit.internal.runners.JUnit38ClassRunner; import org.junit.runner.Description; import org.junit.runner.JUnitCore; import org.junit.runner.Result; @@ -21,7 +21,7 @@ } @Test public void plansDecoratorCorrectly() { - OldTestClassRunner runner= new OldTestClassRunner(new TestDecorator(new TestSuite(MyTest.class))); + JUnit38ClassRunner runner= new JUnit38ClassRunner(new TestDecorator(new TestSuite(MyTest.class))); assertEquals(1, runner.testCount()); } @@ -32,7 +32,7 @@ } @Test public void canUnadaptAnAdapter() { - OldTestClassRunner runner= new OldTestClassRunner(new JUnit4TestAdapter(AnnotatedTest.class)); + JUnit38ClassRunner runner= new JUnit38ClassRunner(new JUnit4TestAdapter(AnnotatedTest.class)); Result result= new JUnitCore().run(runner); Failure failure= result.getFailures().get(0); assertEquals(Description.createTestDescription(AnnotatedTest.class, "foo"), failure.getDescription()); Index: InaccessibleBaseClassTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/InaccessibleBaseClassTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- InaccessibleBaseClassTest.java 21 Feb 2007 14:46:51 -0000 1.2 +++ InaccessibleBaseClassTest.java 20 Mar 2007 14:43:49 -0000 1.3 @@ -3,12 +3,13 @@ import org.junit.Test; import org.junit.internal.runners.InitializationError; import org.junit.internal.runners.MethodValidator; +import org.junit.internal.runners.TestClass; import org.junit.tests.anotherpackage.Sub; public class InaccessibleBaseClassTest { @Test(expected=InitializationError.class) public void inaccessibleBaseClassIsCaughtAtValidation() throws InitializationError { - MethodValidator methodValidator= new MethodValidator(Sub.class); + MethodValidator methodValidator= new MethodValidator(new TestClass(Sub.class)); methodValidator.validateMethodsForDefaultRunner(); methodValidator.assertValid(); } Index: ParameterizedTestMethodTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/ParameterizedTestMethodTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ParameterizedTestMethodTest.java 21 Nov 2006 18:53:34 -0000 1.1 +++ ParameterizedTestMethodTest.java 20 Mar 2007 14:43:49 -0000 1.2 @@ -14,7 +14,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.internal.runners.InitializationError; -import org.junit.internal.runners.TestClassRunner; +import org.junit.internal.runners.JUnit4ClassRunner; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -85,7 +85,7 @@ private List<Throwable> validateAllMethods(Class<?> clazz) { try { - new TestClassRunner(clazz); + new JUnit4ClassRunner(clazz); } catch (InitializationError e) { return e.getCauses(); } Index: InitializationErrorForwardCompatibilityTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/InitializationErrorForwardCompatibilityTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- InitializationErrorForwardCompatibilityTest.java 2 Mar 2007 16:19:25 -0000 1.3 +++ InitializationErrorForwardCompatibilityTest.java 20 Mar 2007 14:43:49 -0000 1.4 @@ -9,7 +9,7 @@ import junit.framework.TestResult; import org.junit.Before; import org.junit.Test; -import org.junit.internal.runners.TestClassRunner; +import org.junit.internal.runners.JUnit4ClassRunner; import org.junit.runner.Description; import org.junit.runner.RunWith; import org.junit.runner.Runner; @@ -91,7 +91,7 @@ assertTrue(shouldFail == listener.getError()); } - public static class InitializesWithError extends TestClassRunner { + public static class InitializesWithError extends JUnit4ClassRunner { public InitializesWithError(Class<?> klass) throws Exception { super(klass); throw new Exception(); Index: SingleMethodTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/SingleMethodTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SingleMethodTest.java 21 Nov 2006 18:53:33 -0000 1.1 +++ SingleMethodTest.java 20 Mar 2007 14:43:49 -0000 1.2 @@ -49,7 +49,7 @@ @Parameters public static Collection<Object[]> params() { return Parameterized.eachOne(1, 2); - } + } public ParameterizedOneTimeSetup(int x) { } Index: SortableTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/SortableTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SortableTest.java 2 Mar 2007 16:19:25 -0000 1.3 +++ SortableTest.java 20 Mar 2007 14:43:49 -0000 1.4 @@ -6,14 +6,11 @@ import org.junit.Before; import org.junit.Test; -import org.junit.internal.runners.InitializationError; -import org.junit.internal.runners.TestClassRunner; import org.junit.runner.Description; import org.junit.runner.JUnitCore; import org.junit.runner.Request; import org.junit.runner.RunWith; import org.junit.runner.Runner; -import org.junit.runner.manipulation.Sorter; import org.junit.runner.notification.RunNotifier; import org.junit.runners.Enclosed; @@ -116,10 +113,5 @@ Request unsorted= Request.aClass(Unsortable.class).sortWith(forward()); new JUnitCore().run(unsorted); } - - @Test public void testClassRunnerCanBeWrappedAroundUnsortable() throws InitializationError { - TestClassRunner runner= new TestClassRunner(Unsortable.class, new UnsortableRunner(Unsortable.class)); - runner.sort(new Sorter(forward())); - } } } Index: OldTestClassAdaptingListenerTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/OldTestClassAdaptingListenerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- OldTestClassAdaptingListenerTest.java 2 Mar 2007 16:19:25 -0000 1.2 +++ OldTestClassAdaptingListenerTest.java 20 Mar 2007 14:43:49 -0000 1.3 @@ -5,7 +5,7 @@ import junit.framework.TestCase; import junit.framework.TestListener; import org.junit.Test; -import org.junit.internal.runners.OldTestClassRunner; +import org.junit.internal.runners.JUnit38ClassRunner; import org.junit.runner.Result; import org.junit.runner.notification.RunListener; import org.junit.runner.notification.RunNotifier; @@ -17,7 +17,7 @@ RunListener listener= result.createListener(); RunNotifier notifier= new RunNotifier(); notifier.addFirstListener(listener); - TestListener adaptingListener= OldTestClassRunner + TestListener adaptingListener= JUnit38ClassRunner .createAdaptingListener(notifier); TestCase testCase= new TestCase() { }; Index: TextListenerTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/TextListenerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TextListenerTest.java 6 Dec 2006 01:22:48 -0000 1.2 +++ TextListenerTest.java 20 Mar 2007 14:43:49 -0000 1.3 @@ -6,7 +6,7 @@ import junit.framework.TestCase; import org.junit.Test; -import org.junit.internal.runners.TextListener; +import org.junit.internal.TextListener; import org.junit.runner.JUnitCore; public class TextListenerTest extends TestCase { Index: AnnotationTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/AnnotationTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- AnnotationTest.java 21 Nov 2006 18:53:33 -0000 1.1 +++ AnnotationTest.java 20 Mar 2007 14:43:49 -0000 1.2 @@ -264,6 +264,9 @@ static public class NonStaticOneTimeSetup { @BeforeClass public void once() { } + + @Test public void aTest() { + } } public void testNonStaticOneTimeSetup() throws Exception { Index: TestMethodTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/TestMethodTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- TestMethodTest.java 21 Feb 2007 14:46:51 -0000 1.4 +++ TestMethodTest.java 20 Mar 2007 14:43:49 -0000 1.5 @@ -16,7 +16,8 @@ import org.junit.Test; import org.junit.internal.runners.InitializationError; import org.junit.internal.runners.MethodValidator; -import org.junit.internal.runners.TestClassRunner; +import org.junit.internal.runners.TestClass; +import org.junit.internal.runners.JUnit4ClassRunner; import org.junit.runner.JUnitCore; import org.junit.runner.Result; @@ -86,7 +87,7 @@ private List<Throwable> validateAllMethods(Class<?> clazz) { try { - new TestClassRunner(clazz); + new JUnit4ClassRunner(clazz); } catch (InitializationError e) { return e.getCauses(); } @@ -120,7 +121,7 @@ } @Test public void overloaded() { - MethodValidator validator= new MethodValidator(Confused.class); + MethodValidator validator= new MethodValidator(new TestClass(Confused.class)); List<Throwable> errors= validator.validateMethodsForDefaultRunner(); assertEquals(1, errors.size()); } Index: UserStopTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/UserStopTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- UserStopTest.java 21 Nov 2006 18:53:33 -0000 1.1 +++ UserStopTest.java 20 Mar 2007 14:43:49 -0000 1.2 @@ -2,8 +2,6 @@ import org.junit.Before; import org.junit.Test; -import org.junit.internal.runners.TestMethodRunner; -import org.junit.runner.Description; import org.junit.runner.Request; import org.junit.runner.notification.RunNotifier; import org.junit.runner.notification.StoppedByUserException; @@ -20,10 +18,12 @@ fNotifier.fireTestStarted(null); } - @Test(expected=StoppedByUserException.class) public void stopMethodRunner() throws Exception { - new TestMethodRunner(this, OneTest.class.getMethod("foo"), fNotifier, - Description.createTestDescription(OneTest.class, "foo")).run(); - } + + // TODO: API is changing +// @Test(expected=StoppedByUserException.class) public void stopMethodRunner() throws Exception { +// new TestMethodRunner(this, OneTest.class.getMethod("foo"), fNotifier, +// Description.createTestDescription(OneTest.class, "foo")).run(); +// } public static class OneTest { @Test public void foo() {} Index: ParameterizedTestTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/ParameterizedTestTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ParameterizedTestTest.java 6 Dec 2006 01:22:48 -0000 1.2 +++ ParameterizedTestTest.java 20 Mar 2007 14:43:49 -0000 1.3 @@ -91,6 +91,9 @@ public static Collection<Object[]> data() { return Collections.emptyList(); } + + @Test public void aTest() { + } } @Test @@ -144,6 +147,9 @@ protected static Collection<Object[]> data() { return Collections.emptyList(); } + + @Test public void aTest() { + } } @Test @@ -161,6 +167,9 @@ public static Collection<String> data() { return Arrays.asList("a", "b", "c"); } + + @Test public void aTest() { + } } @Test public void meaningfulFailureWhenParameterListsAreNotArrays() { Index: ValidationTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/ValidationTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ValidationTest.java 2 Mar 2007 16:19:25 -0000 1.3 +++ ValidationTest.java 20 Mar 2007 14:43:49 -0000 1.4 @@ -3,12 +3,7 @@ import static org.junit.Assert.assertEquals; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.internal.runners.InitializationError; -import org.junit.internal.runners.TestClassRunner; -import org.junit.runner.Description; import org.junit.runner.Request; -import org.junit.runner.Runner; -import org.junit.runner.notification.RunNotifier; public class ValidationTest { public static class WrongBeforeClass { @@ -17,21 +12,6 @@ return 0; } } - - @Test(expected=InitializationError.class) - public void testClassRunnerHandlesBeforeClassAndAfterClassValidation() throws InitializationError { - new TestClassRunner(WrongBeforeClass.class, new Runner() { - @Override - public Description getDescription() { - return Description.EMPTY; - } - - @Override - public void run(RunNotifier notifier) { - // do nothing - } - }); - } @Test public void initializationErrorIsOnCorrectClass() { |
From: David S. <ds...@us...> - 2007-03-20 14:43:58
|
Update of /cvsroot/junit/junit/build/experimental-use-of-antunit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16775/build/experimental-use-of-antunit Modified Files: junit.ant build.xml junit-slow.ant Added Files: macros.ant junit-remote.ant Log Message: Fix upload ant task, and cleaned up ant tests --- NEW FILE: macros.ant --- <project> <property file="junit.properties" /> <!-- is called prior to the test --> <target name="setUp"> </target> <!-- is called after the test, even if that caused an error --> <target name="tearDown"> <delete dir="${antdistdir}" /> <delete dir="${tempdir}" /> <delete file="${exttestjavadoczip}" /> </target> <macrodef name="junitbuild"> <attribute name="target" /> <sequential> <ant antfile="build.xml" target="@{target}" dir="${junitdir}"> <property name="dist" value="${antdist}" /> <property name="javadocdir" value="${antdist}/ant-unit-java-docs" /> <property name="javadoczip" value="${testjavadoczip}" /> <property name="javadocpackages" value="org.junit" /> </ant> </sequential> </macrodef> </project> --- NEW FILE: junit-remote.ant --- <project xmlns:au="antlib:org.apache.ant.antunit"> <import file="macros.ant"/> <target name="testCharacterize_Upload"> <!-- TODO: DUP --> <ant antfile="build.xml" target="clean" dir="${junitdir}"> <property name="dist" value="${antdist}" /> </ant> <!-- Should work --> <ant antfile="build.xml" target="upload.to.sourceforge" dir="${junitdir}"> <property name="dist" value="${antdist}" /> </ant> </target> </project> Index: junit.ant =================================================================== RCS file: /cvsroot/junit/junit/build/experimental-use-of-antunit/junit.ant,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- junit.ant 10 Mar 2007 07:10:32 -0000 1.1 +++ junit.ant 20 Mar 2007 14:12:23 -0000 1.2 @@ -1,30 +1,5 @@ <project xmlns:au="antlib:org.apache.ant.antunit"> - <property file="junit.properties" /> - - <!-- is called prior to the test --> - <target name="setUp"> - </target> - - <!-- is called after the test, even if that caused an error --> - <target name="tearDown"> - <delete dir="${antdistdir}" /> - <delete dir="${tempdir}" /> - <delete file="${exttestjavadoczip}" /> - </target> - - <macrodef name="junitbuild"> - <attribute name="target" /> - <sequential> - <ant antfile="build.xml" target="@{target}" dir="${junitdir}"> - <property name="dist" value="${antdist}" /> - <property name="javadocdir" - value="${antdist}/ant-unit-java-docs" - /> - <property name="javadoczip" value="${testjavadoczip}" /> - <property name="javadocpackages" value="org.junit" /> - </ant> - </sequential> - </macrodef> + <import file="macros.ant"/> <macrodef name="sizeOfDir"> <attribute name="property.name" /> Index: build.xml =================================================================== RCS file: /cvsroot/junit/junit/build/experimental-use-of-antunit/build.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- build.xml 10 Mar 2007 07:10:32 -0000 1.1 +++ build.xml 20 Mar 2007 14:12:23 -0000 1.2 @@ -4,17 +4,25 @@ classpath="lib/ant-antunit-1.0.jar" /> + <macrodef name="antunit.plain"> + <attribute name="includes" /> + <sequential> + <au:antunit> + <fileset dir="." includes="@{includes}" /> + <au:plainlistener /> + </au:antunit> + </sequential> + </macrodef> + <target name="fast"> - <au:antunit> - <fileset dir="." includes="touch.ant,junit.ant" /> - <au:plainlistener /> - </au:antunit> + <antunit.plain includes="touch.ant,junit.ant" /> </target> - <target name="all"> - <au:antunit> - <fileset dir="." includes="touch.ant,junit.ant,junit-slow.ant" /> - <au:plainlistener /> - </au:antunit> + <target name="all" depends="fast"> + <antunit.plain includes="junit-slow.ant" /> + </target> + + <target name="remote"> + <antunit.plain includes="junit-remote.ant" /> </target> </project> \ No newline at end of file Index: junit-slow.ant =================================================================== RCS file: /cvsroot/junit/junit/build/experimental-use-of-antunit/junit-slow.ant,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- junit-slow.ant 10 Mar 2007 07:10:32 -0000 1.1 +++ junit-slow.ant 20 Mar 2007 14:12:23 -0000 1.2 @@ -1,14 +1,5 @@ <project xmlns:au="antlib:org.apache.ant.antunit"> - <property file="junit.properties" /> - - <!-- is called prior to the test --> - <target name="setUp"> - </target> - - <!-- is called after the test, even if that caused an error --> - <target name="tearDown"> - <delete dir="${antdistdir}" /> - </target> + <import file="macros.ant"/> <target name="testTearDown"> <mkdir dir="${antdistdir}"/> |
From: David S. <ds...@us...> - 2007-03-20 14:43:58
|
Update of /cvsroot/junit/junit In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16775 Modified Files: build.xml Log Message: Fix upload ant task, and cleaned up ant tests Index: build.xml =================================================================== RCS file: /cvsroot/junit/junit/build.xml,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- build.xml 10 Mar 2007 07:10:32 -0000 1.24 +++ build.xml 20 Mar 2007 14:12:23 -0000 1.25 @@ -117,7 +117,7 @@ <delete file="${javadoczip}" /> </target> - <target name="upload.to.sourceforge"> + <target name="upload.to.sourceforge" depends="zip"> <ftp server="upload.sourceforge.net" userid="anonymous" password="sa...@mi..." |
From: David S. <ds...@us...> - 2007-03-20 14:43:57
|
Update of /cvsroot/junit/junit/src/org/junit/runners In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30152/src/org/junit/runners Modified Files: package-info.java Parameterized.java Suite.java AllTests.java Log Message: Runner rearchitecting to begin 4.4 development Index: package-info.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/runners/package-info.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- package-info.java 21 Nov 2006 18:53:41 -0000 1.1 +++ package-info.java 20 Mar 2007 14:43:50 -0000 1.2 @@ -3,6 +3,6 @@ * * @since 4.0 * @see org.junit.runner.Runner - * @see org.junit.internal.runners.TestClassRunner + * @see org.junit.internal.runners.TryToDoEverythingRunner */ package org.junit.runners; \ No newline at end of file Index: Parameterized.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/runners/Parameterized.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Parameterized.java 27 Dec 2006 17:45:54 -0000 1.2 +++ Parameterized.java 20 Mar 2007 14:43:50 -0000 1.3 @@ -1,8 +1,5 @@ package org.junit.runners; -import static org.junit.Assert.assertEquals; - -import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -15,10 +12,14 @@ import java.util.Collection; import java.util.List; +import org.junit.Assert; import org.junit.internal.runners.CompositeRunner; +import org.junit.internal.runners.InitializationError; import org.junit.internal.runners.MethodValidator; -import org.junit.internal.runners.TestClassMethodsRunner; -import org.junit.internal.runners.TestClassRunner; +import org.junit.internal.runners.TestClass; +import org.junit.internal.runners.JUnit4ClassRunner; +import org.junit.internal.runners.ClassRoadie; +import org.junit.runner.notification.RunNotifier; /** <p>The custom runner <code>Parameterized</code> implements parameterized * tests. When running a parameterized test class, instances are created for the @@ -51,30 +52,16 @@ * <p>Each instance of <code>FibonacciTest</code> will be constructed using the two-argument * constructor and the data values in the <code>@Parameters</code> method.</p> */ -public class Parameterized extends TestClassRunner { - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public static @interface Parameters { - } - - public static Collection<Object[]> eachOne(Object... params) { - List<Object[]> results= new ArrayList<Object[]>(); - for (Object param : params) - results.add(new Object[] { param }); - return results; - } - - // TODO: single-class this extension - - private static class TestClassRunnerForParameters extends TestClassMethodsRunner { +public class Parameterized extends CompositeRunner { + static class TestClassRunnerForParameters extends JUnit4ClassRunner { private final Object[] fParameters; private final int fParameterSetNumber; private final Constructor<?> fConstructor; - private TestClassRunnerForParameters(Class<?> klass, Object[] parameters, int i) { - super(klass); + TestClassRunnerForParameters(TestClass testClass, Object[] parameters, int i) throws InitializationError { + super(testClass.getJavaClass()); //todo fParameters= parameters; fParameterSetNumber= i; fConstructor= getOnlyConstructor(); @@ -96,55 +83,78 @@ } private Constructor<?> getOnlyConstructor() { - Constructor<?>[] constructors= getTestClass().getConstructors(); - assertEquals(1, constructors.length); + Constructor<?>[] constructors= getTestClass().getJavaClass().getConstructors(); + Assert.assertEquals(1, constructors.length); return constructors[0]; } + + @Override + protected void validate() throws InitializationError { + // do nothing: validated before. + } + + @Override + public void run(RunNotifier notifier) { + runMethods(notifier); + } } - - // TODO: I think this now eagerly reads parameters, which was never the point. - - public static class RunAllParameterMethods extends CompositeRunner { - private final Class<?> fKlass; - public RunAllParameterMethods(Class<?> klass) throws Exception { - super(klass.getName()); - fKlass= klass; - int i= 0; - for (final Object each : getParametersList()) { - if (each instanceof Object[]) - super.add(new TestClassRunnerForParameters(klass, (Object[])each, i++)); - else - throw new Exception(String.format("%s.%s() must return a Collection of arrays.", fKlass.getName(), getParametersMethod().getName())); - } - } + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public static @interface Parameters { + } + + private final TestClass fTestClass; - private Collection<?> getParametersList() throws IllegalAccessException, InvocationTargetException, Exception { - return (Collection<?>) getParametersMethod().invoke(null); - } + public Parameterized(Class<?> klass) throws Exception { + super(klass.getName()); + fTestClass= new TestClass(klass); - private Method getParametersMethod() throws Exception { - for (Method each : fKlass.getMethods()) { - if (Modifier.isStatic(each.getModifiers())) { - Annotation[] annotations= each.getAnnotations(); - for (Annotation annotation : annotations) { - if (annotation.annotationType() == Parameters.class) - return each; - } - } - } - throw new Exception("No public static parameters method on class " - + getName()); + MethodValidator methodValidator= new MethodValidator(fTestClass); + methodValidator.validateStaticMethods(); + methodValidator.validateInstanceMethods(); + methodValidator.assertValid(); + + int i= 0; + for (final Object each : getParametersList()) { + if (each instanceof Object[]) + add(new TestClassRunnerForParameters(fTestClass, (Object[])each, i++)); + else + throw new Exception(String.format("%s.%s() must return a Collection of arrays.", fTestClass.getName(), getParametersMethod().getName())); } } - public Parameterized(final Class<?> klass) throws Exception { - super(klass, new RunAllParameterMethods(klass)); + @Override + public void run(final RunNotifier notifier) { + new ClassRoadie(notifier, fTestClass, getDescription(), new Runnable() { + public void run() { + runChildren(notifier); + } + }).runProtected(); } - @Override - protected void validate(MethodValidator methodValidator) { - methodValidator.validateStaticMethods(); - methodValidator.validateInstanceMethods(); + private Collection<?> getParametersList() throws IllegalAccessException, InvocationTargetException, Exception { + return (Collection<?>) getParametersMethod().invoke(null); + } + + private Method getParametersMethod() throws Exception { + List<Method> methods= fTestClass.getAnnotatedMethods(Parameters.class); + for (Method each : methods) { + int modifiers= each.getModifiers(); + if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) + return each; + } + + throw new Exception("No public static parameters method on class " + getName()); + } + + public static Collection<Object[]> eachOne(Object... params) { + List<Object[]> results= new ArrayList<Object[]>(); + for (Object param : params) + results.add(new Object[] { param }); + return results; } } + +// TODO: single-class this extension + Index: Suite.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/runners/Suite.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Suite.java 21 Feb 2007 20:26:29 -0000 1.3 +++ Suite.java 20 Mar 2007 14:43:50 -0000 1.4 @@ -7,10 +7,14 @@ import java.util.HashSet; import java.util.Set; +import org.junit.internal.runners.CompositeRunner; import org.junit.internal.runners.InitializationError; import org.junit.internal.runners.MethodValidator; -import org.junit.internal.runners.TestClassRunner; +import org.junit.internal.runners.TestClass; +import org.junit.internal.runners.ClassRoadie; import org.junit.runner.Request; +import org.junit.runner.Runner; +import org.junit.runner.notification.RunNotifier; /** * Using <code>Suite</code> as a runner allows you to manually @@ -19,7 +23,7 @@ * with <code>@RunWith(Suite.class)</code> and <code>@SuiteClasses(TestClass1.class, ...)</code>. * When you run this class, it will run all the tests in all the suite classes. */ -public class Suite extends TestClassRunner { +public class Suite extends CompositeRunner { /** * The <code>SuiteClasses</code> annotation specifies the classes to be run when a class * annotated with <code>@RunWith(Suite.class)</code> is run. @@ -40,15 +44,33 @@ // This won't work correctly in the face of concurrency. For that we need to // add parameters to getRunner(), which would be much more complicated. private static Set<Class<?>> parents = new HashSet<Class<?>>(); + private TestClass fTestClass; - private static Class<?> addParent(Class<?> parent) throws InitializationError { + protected Suite(Class<?> klass, Class<?>[] annotatedClasses) throws InitializationError { + // we need to add parent be + super(klass.getName()); + + addParent(klass); + for (Class<?> each : annotatedClasses) { + Runner childRunner= Request.aClass(each).getRunner(); + if (childRunner != null) + add(childRunner); + } + removeParent(klass); + + fTestClass= new TestClass(klass); + MethodValidator methodValidator= new MethodValidator(fTestClass); + methodValidator.validateStaticMethods(); + methodValidator.assertValid(); + } + + private Class<?> addParent(Class<?> parent) throws InitializationError { if (!parents.add(parent)) throw new InitializationError(String.format("class '%s' (possibly indirectly) contains itself as a SuiteClass", parent.getName())); return parent; } - protected Suite(Class<?> klass, Class<?>[] annotatedClasses) throws InitializationError { - super(addParent(klass), Request.classes(klass.getName(), annotatedClasses).getRunner()); + private void removeParent(Class<?> klass) { parents.remove(klass); } @@ -59,9 +81,17 @@ return annotation.value(); } - @Override protected void validate(MethodValidator methodValidator) { methodValidator.validateStaticMethods(); methodValidator.validateInstanceMethods(); } + + @Override + public void run(final RunNotifier notifier) { + new ClassRoadie(notifier, fTestClass, getDescription(), new Runnable() { + public void run() { + runChildren(notifier); + } + }).runProtected(); + } } Index: AllTests.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/runners/AllTests.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- AllTests.java 21 Feb 2007 15:19:39 -0000 1.3 +++ AllTests.java 20 Mar 2007 14:43:50 -0000 1.4 @@ -5,7 +5,7 @@ import java.lang.reflect.Modifier; import junit.framework.Test; -import org.junit.internal.runners.OldTestClassRunner; +import org.junit.internal.runners.JUnit38ClassRunner; /** Runner for use with JUnit 3.8.x-style AllTests classes * (those that only implement a static <code>suite()</code> @@ -19,7 +19,7 @@ * } * </pre> */ -public class AllTests extends OldTestClassRunner { +public class AllTests extends JUnit38ClassRunner { @SuppressWarnings("unchecked") public AllTests(Class<?> klass) throws Throwable { super(testFromSuiteMethod(klass)); |
Update of /cvsroot/junit/junit/src/org/junit/internal/runners In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30152/src/org/junit/internal/runners Modified Files: CompositeRunner.java MethodValidator.java Added Files: TestClass.java MethodRoadie.java JUnit38ClassRunner.java TestMethod.java JUnit4ClassRunner.java FailedBefore.java ClassRoadie.java Removed Files: TestIntrospector.java TextListener.java TestClassRunner.java TestClassMethodsRunner.java OldTestClassRunner.java TestMethodRunner.java BeforeAndAfterRunner.java Log Message: Runner rearchitecting to begin 4.4 development --- NEW FILE: TestClass.java --- package org.junit.internal.runners; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; public class TestClass { private final Class<?> fClass; public TestClass(Class<?> klass) { fClass= klass; } List<Method> getTestMethods() { return getAnnotatedMethods(Test.class); } public List<Method> getBefores() { return getAnnotatedMethods(BeforeClass.class); } public List<Method> getAfters() { return getAnnotatedMethods(AfterClass.class); } public List<Method> getAnnotatedMethods(Class<? extends Annotation> annotationClass) { List<Method> results= new ArrayList<Method>(); for (Class<?> eachClass : getSuperClasses(fClass)) { Method[] methods= eachClass.getDeclaredMethods(); for (Method eachMethod : methods) { Annotation annotation= eachMethod.getAnnotation(annotationClass); if (annotation != null && ! isShadowed(eachMethod, results)) results.add(eachMethod); } } if (runsTopToBottom(annotationClass)) Collections.reverse(results); return results; } private boolean runsTopToBottom(Class< ? extends Annotation> annotation) { return annotation.equals(Before.class) || annotation.equals(BeforeClass.class); } private boolean isShadowed(Method method, List<Method> results) { for (Method each : results) { if (isShadowed(method, each)) return true; } return false; } private boolean isShadowed(Method current, Method previous) { if (! previous.getName().equals(current.getName())) return false; if (previous.getParameterTypes().length != current.getParameterTypes().length) return false; for (int i= 0; i < previous.getParameterTypes().length; i++) { if (! previous.getParameterTypes()[i].equals(current.getParameterTypes()[i])) return false; } return true; } private List<Class<?>> getSuperClasses(Class< ?> testClass) { ArrayList<Class<?>> results= new ArrayList<Class<?>>(); Class<?> current= testClass; while (current != null) { results.add(current); current= current.getSuperclass(); } return results; } public Constructor<?> getConstructor() throws SecurityException, NoSuchMethodException { return fClass.getConstructor(); } public Class<?> getJavaClass() { return fClass; } public String getName() { return fClass.getName(); } } --- NEW FILE: MethodRoadie.java --- package org.junit.internal.runners; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.junit.runner.Description; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; public class MethodRoadie { private final Object fTest; private final Method fMethod; private final RunNotifier fNotifier; private final Description fDescription; private TestMethod fTestMethod; public MethodRoadie(Object test, Method method, RunNotifier notifier, Description description, TestClass testClass) { fTest= test; fMethod= method; fNotifier= notifier; fDescription= description; fTestMethod= new TestMethod(method, testClass); } public void run() { if (fTestMethod.isIgnored()) { fNotifier.fireTestIgnored(fDescription); return; } fNotifier.fireTestStarted(fDescription); try { long timeout= fTestMethod.getTimeout(); if (timeout > 0) runWithTimeout(timeout); else runTest(); } finally { fNotifier.fireTestFinished(fDescription); } } private void runWithTimeout(long timeout) { ExecutorService service= Executors.newSingleThreadExecutor(); Callable<Object> callable= new Callable<Object>() { public Object call() throws Exception { runTest(); return null; } }; Future<Object> result= service.submit(callable); service.shutdown(); try { boolean terminated= service.awaitTermination(timeout, TimeUnit.MILLISECONDS); if (!terminated) service.shutdownNow(); result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation } catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); } catch (Exception e) { addFailure(e); } } public void runTest() { try { runBefores(); runTestMethod(); } catch (FailedBefore e) { } finally { runAfters(); } } protected void runTestMethod() { try { fMethod.invoke(fTest); if (fTestMethod.expectsException()) addFailure(new AssertionError("Expected exception: " + fTestMethod.getExpectedException().getName())); } catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } } catch (Throwable e) { addFailure(e); } } private void runBefores() throws FailedBefore { try { List<Method> befores= fTestMethod.getBefores(); for (Method before : befores) before.invoke(fTest); } catch (InvocationTargetException e) { addFailure(e.getTargetException()); throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } } private void runAfters() { List<Method> afters= fTestMethod.getAfters(); for (Method after : afters) try { after.invoke(fTest); } catch (InvocationTargetException e) { addFailure(e.getTargetException()); } catch (Throwable e) { addFailure(e); // Untested, but seems impossible } } protected void addFailure(Throwable e) { fNotifier.fireTestFailure(new Failure(fDescription, e)); } } --- NEW FILE: JUnit38ClassRunner.java --- package org.junit.internal.runners; import junit.extensions.TestDecorator; import junit.framework.AssertionFailedError; import junit.framework.JUnit4TestAdapter; import junit.framework.JUnit4TestCaseFacade; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestListener; import junit.framework.TestResult; import junit.framework.TestSuite; import org.junit.runner.Description; import org.junit.runner.Runner; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; public class JUnit38ClassRunner extends Runner { private static final class OldTestClassAdaptingListener implements TestListener { private final RunNotifier fNotifier; private OldTestClassAdaptingListener(RunNotifier notifier) { fNotifier= notifier; } public void endTest(Test test) { fNotifier.fireTestFinished(asDescription(test)); } public void startTest(Test test) { fNotifier.fireTestStarted(asDescription(test)); } // Implement junit.framework.TestListener public void addError(Test test, Throwable t) { Failure failure= new Failure(asDescription(test), t); fNotifier.fireTestFailure(failure); } private Description asDescription(Test test) { if (test instanceof JUnit4TestCaseFacade) { JUnit4TestCaseFacade facade= (JUnit4TestCaseFacade) test; return facade.getDescription(); } return Description.createTestDescription(test.getClass(), getName(test)); } private String getName(Test test) { if (test instanceof TestCase) return ((TestCase) test).getName(); else return test.toString(); } public void addFailure(Test test, AssertionFailedError t) { addError(test, t); } } private Test fTest; @SuppressWarnings("unchecked") public JUnit38ClassRunner(Class<?> klass) { this(new TestSuite(klass.asSubclass(TestCase.class))); } public JUnit38ClassRunner(Test test) { super(); fTest= test; } @Override public void run(RunNotifier notifier) { TestResult result= new TestResult(); result.addListener(createAdaptingListener(notifier)); fTest.run(result); } public static TestListener createAdaptingListener(final RunNotifier notifier) { return new OldTestClassAdaptingListener(notifier); } @Override public Description getDescription() { return makeDescription(fTest); } private Description makeDescription(Test test) { if (test instanceof TestCase) { TestCase tc= (TestCase) test; return Description.createTestDescription(tc.getClass(), tc.getName()); } else if (test instanceof TestSuite) { TestSuite ts= (TestSuite) test; String name= ts.getName() == null ? "" : ts.getName(); Description description= Description.createSuiteDescription(name); int n= ts.testCount(); for (int i= 0; i < n; i++) description.addChild(makeDescription(ts.testAt(i))); return description; } else if (test instanceof JUnit4TestAdapter) { JUnit4TestAdapter adapter= (JUnit4TestAdapter) test; return adapter.getDescription(); } else if (test instanceof TestDecorator) { TestDecorator decorator= (TestDecorator) test; return makeDescription(decorator.getTest()); } else { // This is the best we can do in this case return Description.createSuiteDescription(test.getClass()); } } } --- NEW FILE: JUnit4ClassRunner.java --- package org.junit.internal.runners; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import org.junit.runner.Description; import org.junit.runner.Runner; import org.junit.runner.manipulation.Filter; import org.junit.runner.manipulation.Filterable; import org.junit.runner.manipulation.NoTestsRemainException; import org.junit.runner.manipulation.Sortable; import org.junit.runner.manipulation.Sorter; import org.junit.runner.notification.RunNotifier; public class JUnit4ClassRunner extends Runner implements Filterable, Sortable { private final List<Method> fTestMethods; private TestClass fTestClass; public JUnit4ClassRunner(Class<?> klass) throws InitializationError { fTestClass= new TestClass(klass); fTestMethods= fTestClass.getTestMethods(); validate(); } protected void validate() throws InitializationError { MethodValidator methodValidator= new MethodValidator(fTestClass); methodValidator.validateMethodsForDefaultRunner(); methodValidator.assertValid(); } @Override public void run(final RunNotifier notifier) { new ClassRoadie(notifier, fTestClass, getDescription(), new Runnable() { public void run() { runMethods(notifier); } }).runProtected(); } protected void runMethods(final RunNotifier notifier) { for (Method method : fTestMethods) invokeTestMethod(method, notifier); } @Override public Description getDescription() { Description spec= Description.createSuiteDescription(getName()); List<Method> testMethods= fTestMethods; for (Method method : testMethods) spec.addChild(methodDescription(method)); return spec; } protected String getName() { return getTestClass().getName(); } protected Object createTest() throws Exception { return getTestClass().getConstructor().newInstance(); } protected void invokeTestMethod(Method method, RunNotifier notifier) { Object test; try { test= createTest(); } catch (InvocationTargetException e) { notifier.testAborted(methodDescription(method), e.getCause()); return; } catch (Exception e) { notifier.testAborted(methodDescription(method), e); return; } createMethodRunner(test, method, notifier).run(); } protected MethodRoadie createMethodRunner(Object test, Method method, RunNotifier notifier) { return new MethodRoadie(test, method, notifier, methodDescription(method), fTestClass); } protected String testName(Method method) { return method.getName(); } protected Description methodDescription(Method method) { return Description.createTestDescription(getTestClass().getJavaClass(), testName(method)); } public void filter(Filter filter) throws NoTestsRemainException { for (Iterator<Method> iter= fTestMethods.iterator(); iter.hasNext();) { Method method= iter.next(); if (!filter.shouldRun(methodDescription(method))) iter.remove(); } if (fTestMethods.isEmpty()) throw new NoTestsRemainException(); } public void sort(final Sorter sorter) { Collections.sort(fTestMethods, new Comparator<Method>() { public int compare(Method o1, Method o2) { return sorter.compare(methodDescription(o1), methodDescription(o2)); } }); } protected TestClass getTestClass() { return fTestClass; } } --- NEW FILE: FailedBefore.java --- package org.junit.internal.runners; class FailedBefore extends Exception { private static final long serialVersionUID= 1L; } --- NEW FILE: ClassRoadie.java --- package org.junit.internal.runners; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import org.junit.runner.Description; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; public class ClassRoadie { private RunNotifier fNotifier; private TestClass fTestClass; private Description fDescription; private final Runnable fRunnable; public ClassRoadie(RunNotifier notifier, TestClass testClass, Description description, Runnable runnable) { fNotifier= notifier; fTestClass= testClass; fDescription= description; fRunnable= runnable; } protected void runUnprotected() { fRunnable.run(); }; protected void addFailure(Throwable targetException) { fNotifier.fireTestFailure(new Failure(fDescription, targetException)); } public void runProtected() { try { runBefores(); runUnprotected(); } catch (FailedBefore e) { } finally { runAfters(); } } private void runBefores() throws FailedBefore { try { List<Method> befores= fTestClass.getBefores(); for (Method before : befores) before.invoke(null); } catch (InvocationTargetException e) { addFailure(e.getTargetException()); throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } } private void runAfters() { List<Method> afters= fTestClass.getAfters(); for (Method after : afters) try { after.invoke(null); } catch (InvocationTargetException e) { addFailure(e.getTargetException()); } catch (Throwable e) { addFailure(e); // Untested, but seems impossible } } } Index: CompositeRunner.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/internal/runners/CompositeRunner.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CompositeRunner.java 6 Dec 2006 01:22:48 -0000 1.2 +++ CompositeRunner.java 20 Mar 2007 14:43:50 -0000 1.3 @@ -25,6 +25,10 @@ @Override public void run(RunNotifier notifier) { + runChildren(notifier); + } + + protected void runChildren(RunNotifier notifier) { for (Runner each : fRunners) each.run(notifier); } Index: MethodValidator.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/internal/runners/MethodValidator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- MethodValidator.java 21 Feb 2007 14:46:51 -0000 1.4 +++ MethodValidator.java 20 Mar 2007 14:43:50 -0000 1.5 @@ -13,21 +13,23 @@ import org.junit.Test; public class MethodValidator { - private final TestIntrospector fIntrospector; private final List<Throwable> fErrors= new ArrayList<Throwable>(); - private final Class<?> fTestClass; + private TestClass fTestClass; - public MethodValidator(Class<?> testClass) { - fTestClass= testClass; - fIntrospector= new TestIntrospector(testClass); + public MethodValidator(TestClass testClass) { + fTestClass = testClass; } public void validateInstanceMethods() { validateTestMethods(After.class, false); validateTestMethods(Before.class, false); validateTestMethods(Test.class, false); + + List<Method> methods= fTestClass.getAnnotatedMethods(Test.class); + if (methods.size() == 0) + fErrors.add(new Exception("No runnable methods")); } public void validateStaticMethods() { @@ -57,7 +59,8 @@ private void validateTestMethods(Class<? extends Annotation> annotation, boolean isStatic) { - List<Method> methods= fIntrospector.getTestMethods(annotation); + List<Method> methods= fTestClass.getAnnotatedMethods(annotation); + for (Method each : methods) { if (Modifier.isStatic(each.getModifiers()) != isStatic) { String state= isStatic ? "should" : "should not"; --- TestIntrospector.java DELETED --- --- TextListener.java DELETED --- --- TestClassRunner.java DELETED --- --- TestClassMethodsRunner.java DELETED --- --- OldTestClassRunner.java DELETED --- --- TestMethodRunner.java DELETED --- --- BeforeAndAfterRunner.java DELETED --- |