Permalink
Browse files

Merge branch 'master' of git://github.com/KentBeck/junit

Conflicts:
	src/test/java/org/junit/tests/AllTests.java
	src/test/java/org/junit/tests/experimental/rules/ExpectedExceptionRuleTest.java

Merged changes from the HEAD branch

Besides the merged changes also the approach to test for the failure has
been changed to comply to the new way of testing in
ExpectedExceptionTest. That no longer required the changes in
ResultMatchers (with their accompanying tests)
  • Loading branch information...
2 parents e381886 + 3f6e3ef commit 17f7dfc72624253461022acff1d3aa6b9c4056cf @arjenw committed May 24, 2012
Showing with 1,954 additions and 497 deletions.
  1. +72 −33 build.xml
  2. +13 −0 build/maven/junit-dep-pom-template.xml
  3. +1 −2 build/maven/{pom-template.xml → junit-pom-template.xml}
  4. +5 −9 src/main/java/junit/framework/Assert.java
  5. +2 −1 src/main/java/junit/framework/TestSuite.java
  6. +142 −7 src/main/java/org/junit/Assert.java
  7. +41 −0 src/main/java/org/junit/FixMethodOrder.java
  8. +0 −8 src/main/java/org/junit/experimental/results/PrintableResult.java
  9. +0 −20 src/main/java/org/junit/experimental/results/ResultMatchers.java
  10. +1 −4 src/main/java/org/junit/experimental/theories/suppliers/TestedOnSupplier.java
  11. +0 −1 src/main/java/org/junit/internal/JUnitSystem.java
  12. +70 −0 src/main/java/org/junit/internal/MethodSorter.java
  13. +0 −5 src/main/java/org/junit/internal/RealSystem.java
  14. +2 −1 src/main/java/org/junit/internal/matchers/TypeSafeMatcher.java
  15. +9 −3 src/main/java/org/junit/internal/requests/ClassRequest.java
  16. +2 −1 src/main/java/org/junit/internal/runners/TestClass.java
  17. +15 −2 src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java
  18. +113 −20 src/main/java/org/junit/rules/ExpectedException.java
  19. +2 −0 src/main/java/org/junit/rules/MethodRule.java
  20. +13 −2 src/main/java/org/junit/rules/TemporaryFolder.java
  21. +5 −5 src/main/java/org/junit/rules/TestWatcher.java
  22. +1 −1 src/main/java/org/junit/rules/Timeout.java
  23. +1 −1 src/main/java/org/junit/rules/Verifier.java
  24. +40 −24 src/main/java/org/junit/runner/Description.java
  25. +7 −6 src/main/java/org/junit/runner/JUnitCore.java
  26. +37 −12 src/main/java/org/junit/runner/notification/RunNotifier.java
  27. +29 −0 src/main/java/org/junit/runners/MethodSorters.java
  28. +78 −29 src/main/java/org/junit/runners/Parameterized.java
  29. +2 −1 src/main/java/org/junit/runners/model/TestClass.java
  30. +95 −0 src/test/java/org/junit/internal/MethodSorterTest.java
  31. +49 −0 src/test/java/org/junit/runner/notification/RunNotifierTest.java
  32. +7 −3 src/test/java/org/junit/tests/AllTests.java
  33. +0 −5 src/test/java/org/junit/tests/TestSystem.java
  34. +81 −1 src/test/java/org/junit/tests/assertion/AssertionTest.java
  35. +11 −0 src/test/java/org/junit/tests/description/TestDescriptionTest.java
  36. +0 −2 src/test/java/org/junit/tests/experimental/categories/CategoryTest.java
  37. +5 −1 src/test/java/org/junit/tests/experimental/max/DescriptionTest.java
  38. +0 −22 src/test/java/org/junit/tests/experimental/results/ResultMatchersTest.java
  39. +175 −0 src/test/java/org/junit/tests/experimental/rules/EventCollector.java
  40. +0 −242 src/test/java/org/junit/tests/experimental/rules/ExpectedExceptionRuleTest.java
  41. +384 −0 src/test/java/org/junit/tests/experimental/rules/ExpectedExceptionTest.java
  42. +22 −0 src/test/java/org/junit/tests/experimental/rules/TempFolderRuleTest.java
  43. +18 −1 src/test/java/org/junit/tests/experimental/rules/TemporaryFolderUsageTest.java
  44. +32 −0 src/test/java/org/junit/tests/experimental/theories/TestedOnSupplierTest.java
  45. +63 −2 src/test/java/org/junit/tests/internal/runners/statements/FailOnTimeoutTest.java
  46. +2 −5 src/test/java/org/junit/tests/listening/TestListenerTest.java
  47. +30 −6 src/test/java/org/junit/tests/running/classes/ParameterizedTestTest.java
  48. +1 −1 src/test/java/org/junit/tests/running/classes/ParentRunnerTest.java
  49. +6 −3 src/test/java/org/junit/tests/running/core/CommandLineTest.java
  50. +7 −5 src/test/java/org/junit/tests/running/core/JUnitCoreReturnsCorrectExitCodeTest.java
  51. +263 −0 src/test/java/org/junit/tests/running/core/MainRunner.java
View
105 build.xml
@@ -31,6 +31,8 @@
<property name="hamcrestlib" location="lib/hamcrest-core-1.1.jar" />
<property name="hamcrestsrc" location="${dist}/temp.hamcrest.source" />
+ <property name="maven.deploy.goal" value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file" />
+
<target name="init">
<tstamp/>
</target>
@@ -68,6 +70,7 @@
debug="on"
classpath="@{classpath}"
includeantruntime="false"
+ source="1.5"
target="1.5"
>
<compilerarg value="-Xlint:unchecked" />
@@ -103,11 +106,6 @@
<target name="all.maven.jars" depends="jars,javadoc">
<mkdir dir="${dist}" />
<jar
- jarfile="${dist}/${docjar}"
- basedir="${javadocdir}"
- excludes="${unjarred}"
- />
- <jar
jarfile="${dist}/${depsrcjar}"
basedir="${src}"
excludes="${unjarred}, **/*.class"
@@ -219,48 +217,75 @@
<!-- to do automatic build upload, you need the maven ant tasks jar. -->
<!-- therefore, you must run ant as ant -lib build/lib stage.maven -->
- <macrodef name="push.maven.jar">
- <attribute name="jar" />
+ <macrodef name="push.maven.artifact">
+ <attribute name="file" />
<attribute name="pom" />
+ <attribute name="packaging" />
<attribute name="url" />
<attribute name="repo.id" />
<element name="artifact.args" implicit="true" optional="true" />
<sequential>
- <echo message="Pushing to maven: @{jar} -> @{url}" />
<artifact:mvn failonerror="true">
- <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file" />
+ <arg value="${maven.deploy.goal}" />
<arg value="-Durl=@{url}" />
<arg value="-DrepositoryId=@{repo.id}" />
<arg value="-DpomFile=@{pom}" />
- <arg value="-Dfile=@{jar}" />
+ <arg value="-Dfile=@{file}" />
+ <arg value="-Dpackaging=@{packaging}" />
<artifact.args />
<arg value="-Pgpg" />
</artifact:mvn>
</sequential>
</macrodef>
- <macrodef name="push.maven.artifact">
- <attribute name="artifactId" />
+ <macrodef name="push.maven.jar">
+ <attribute name="jar" />
+ <attribute name="pom" />
<attribute name="url" />
<attribute name="repo.id" />
- <attribute name="is.snapshot" default="false" />
+ <element name="artifact.args" implicit="true" optional="true" />
+ <sequential>
+ <echo message="Pushing JAR to Maven: @{jar} -> @{url}" />
+ <push.maven.artifact file="@{jar}" pom="@{pom}" packaging="jar"
+ url="@{url}" repo.id="@{repo.id}">
+ <artifact.args />
+ </push.maven.artifact>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="push.maven.pom">
+ <attribute name="pom" />
+ <attribute name="url" />
+ <attribute name="repo.id" />
+ <element name="artifact.args" implicit="true" optional="true" />
+ <sequential>
+ <echo message="Pushing POM to Maven: @{pom} -> @{url}" />
+ <push.maven.artifact file="@{pom}" pom="@{pom}" packaging="pom"
+ url="@{url}" repo.id="@{repo.id}">
+ <artifact.args />
+ </push.maven.artifact>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="push.junit.maven.artifact">
+ <attribute name="url" />
+ <attribute name="repo.id" />
+ <attribute name="is.snapshot" default="true" />
<sequential>
<local name="m.prefix" />
- <property name="m.prefix" value="${dist}/@{artifactId}-${version}" />
+ <property name="m.prefix" value="${dist}/junit-dep-${version}" />
<local name="m.jar" />
<property name="m.jar" value="${m.prefix}.jar" />
<local name="m.sources.jar" />
<property name="m.sources.jar" value="${m.prefix}-src.jar" />
<local name="m.javadoc.jar" />
<property name="m.javadoc.jar" value="${m.prefix}-javadoc.jar" />
<local name="m.pom" />
- <property name="m.pom" value="${dist}/pom-@{artifactId}.xml" />
+ <property name="m.pom" value="${dist}/pom-junit.xml" />
<filter token="version" value="${version}" />
- <filter token="artifactId" value="@{artifactId}" />
-
<copy
- file="build/maven/pom-template.xml"
+ file="build/maven/junit-pom-template.xml"
tofile="${m.pom}"
filtering="on"
overwrite="true"
@@ -276,7 +301,6 @@
url="@{url}" repo.id="@{repo.id}">
<arg value="-Dclassifier=sources" />
</push.maven.jar>
-
<push.maven.jar jar="${m.javadoc.jar}" pom="${m.pom}"
url="@{url}" repo.id="@{repo.id}">
<arg value="-Dclassifier=javadoc" />
@@ -286,32 +310,47 @@
</sequential>
</macrodef>
+ <macrodef name="push.junit-dep.maven.artifact">
+ <attribute name="url" />
+ <attribute name="repo.id" />
+ <sequential>
+ <local name="m.pom" />
+ <property name="m.pom" value="${dist}/pom-junit-dep.xml" />
+
+ <filter token="version" value="${version}" />
+ <copy
+ file="build/maven/junit-dep-pom-template.xml"
+ tofile="${m.pom}"
+ filtering="on"
+ overwrite="true"
+ />
+
+ <push.maven.pom pom="${m.pom}"
+ url="@{url}" repo.id="@{repo.id}" />
+ </sequential>
+ </macrodef>
+
<target name="stage.maven" depends="all.maven.jars">
<property name="stage.url"
value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />
<property name="stage.repo.id" value="sonatype-nexus-staging" />
- <push.maven.artifact artifactId="junit"
- url="${stage.url}"
- repo.id="${stage.repo.id}"
- is.snapshot="false" />
- <push.maven.artifact artifactId="junit-dep"
- url="${stage.url}"
- repo.id="${stage.repo.id}"
- is.snapshot="false" />
+ <push.junit.maven.artifact url="${stage.url}"
+ repo.id="${stage.repo.id}"
+ is.snapshot="false" />
+ <push.junit-dep.maven.artifact url="${stage.url}"
+ repo.id="${stage.repo.id}" />
</target>
<target name="snapshot.maven" depends="all.maven.jars">
<property name="snapshot.url"
value="https://oss.sonatype.org/content/repositories/snapshots/" />
<property name="snapshot.repo.id" value="sonatype-nexus-snapshots" />
- <push.maven.artifact artifactId="junit"
- url="${snapshot.url}"
- repo.id="${snapshot.repo.id}" />
- <push.maven.artifact artifactId="junit-dep"
- url="${snapshot.url}"
- repo.id="${snapshot.repo.id}" />
+ <push.junit.maven.artifact url="${snapshot.url}"
+ repo.id="${snapshot.repo.id}" />
+ <push.junit-dep.maven.artifact url="${snapshot.url}"
+ repo.id="${snapshot.repo.id}" />
</target>
<target name="print.version">
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>junit</groupId>
+ <artifactId>junit-dep</artifactId>
+ <version>@version@</version>
+ <distributionManagement>
+ <relocation>
+ <artifactId>junit</artifactId>
+ </relocation>
+ </distributionManagement>
+</project>
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>
<groupId>junit</groupId>
- <artifactId>@artifactId@</artifactId>
+ <artifactId>junit</artifactId>
<version>@version@</version>
<name>JUnit</name>
<url>http://junit.org</url>
@@ -62,7 +62,6 @@
<scope>compile</scope>
</dependency>
</dependencies>
-
<properties>
<jdk.version>1.5</jdk.version>
</properties>
@@ -226,8 +226,8 @@ static public void assertNotNull(String message, Object object) {
* Object to check or <code>null</code>
*/
static public void assertNull(Object object) {
- String message = "Expected: <null> but was: " + String.valueOf(object);
- assertNull(message, object);
+ if (object != null)
+ assertNull("Expected: <null> but was: " + object.toString(), object);
}
/**
* Asserts that an object is null. If it is not
@@ -270,16 +270,12 @@ static public void assertNotSame(Object expected, Object actual) {
}
static public void failSame(String message) {
- String formatted= "";
- if (message != null)
- formatted= message+" ";
- fail(formatted+"expected not same");
+ String formatted= (message != null) ? message+" " : "";
+ fail(formatted+"expected not same");
}
static public void failNotSame(String message, Object expected, Object actual) {
- String formatted= "";
- if (message != null)
- formatted= message+" ";
+ String formatted= (message != null) ? message+" " : "";
fail(formatted+"expected same:<"+expected+"> was not:<"+actual+">");
}
@@ -10,6 +10,7 @@
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
+import org.junit.internal.MethodSorter;
/**
* <p>A <code>TestSuite</code> is a <code>Composite</code> of Tests.
@@ -146,7 +147,7 @@ private void addTestsFromTestCase(final Class<?> theClass) {
Class<?> superClass= theClass;
List<String> names= new ArrayList<String>();
while (Test.class.isAssignableFrom(superClass)) {
- for (Method each : superClass.getDeclaredMethods())
+ for (Method each : MethodSorter.getDeclaredMethods(superClass))
addTestMethod(each, names, theClass);
superClass= superClass.getSuperclass();
}
Oops, something went wrong.

0 comments on commit 17f7dfc

Please sign in to comment.