From 70986438ca98df55899e293a72931fc12bb737d9 Mon Sep 17 00:00:00 2001 From: David Saff Date: Tue, 7 Apr 2009 10:31:18 +0800 Subject: [PATCH] Last changes with Kent. Added fixed bugs to Release notes. Updated version number. Updated README.html Signed-off-by: Kent Beck --- README | 2 +- README.html | 114 +++++++++++++++++- doc/ReleaseNotes4.6.html | 7 ++ doc/ReleaseNotes4.6.txt | 30 +++-- doc/markdown.sh | 2 +- src/main/java/junit/runner/Version.java | 2 +- src/main/java/org/junit/Assert.java | 31 +++++ .../org/junit/experimental/max/MaxCore.java | 4 + .../internal/InexactComparisonCriteria.java | 5 +- .../junit/tests/assertion/AssertionTest.java | 9 +- 10 files changed, 181 insertions(+), 25 deletions(-) diff --git a/README b/README index 9daeafb9864c..3533670f18ea 100644 --- a/README +++ b/README @@ -1 +1 @@ -test +Please read README.html \ No newline at end of file diff --git a/README.html b/README.html index f65ca3559100..bfcbfea0bfbb 100644 --- a/README.html +++ b/README.html @@ -18,7 +18,7 @@


(see also JUnit.org)
-
[old date] 8 August 2008 +
6 April 2009

JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.

+ +

Bug fixes

+ +
    +
  • Fixed overly permissive @DataPoint processing (2191102)
  • +
  • Fixed bug in test counting after an ignored method (2106324)
  • +
diff --git a/doc/ReleaseNotes4.6.txt b/doc/ReleaseNotes4.6.txt index d7c91359d3a0..a5decac71667 100644 --- a/doc/ReleaseNotes4.6.txt +++ b/doc/ReleaseNotes4.6.txt @@ -2,19 +2,19 @@ ### Max ### -- JUnit now includes a new experimental Core, `MaxCore`. `MaxCore` - remembers the results of previous test runs in order to run new - tests out of order. `MaxCore` prefers new tests to old tests, fast - tests to slow tests, and recently failing tests to tests that last - failed long ago. There's currently not a standard UI for running - `MaxCore` included in JUnit, but there is a UI included in the JUnit - Max Eclipse plug-in at: - - http://www.junitmax.com/junitmax/subscribe.html - - Example: - - public static class TwoUnEqualTests { +JUnit now includes a new experimental Core, `MaxCore`. `MaxCore` +remembers the results of previous test runs in order to run new +tests out of order. `MaxCore` prefers new tests to old tests, fast +tests to slow tests, and recently failing tests to tests that last +failed long ago. There's currently not a standard UI for running +`MaxCore` included in JUnit, but there is a UI included in the JUnit +Max Eclipse plug-in at: + + http://www.junitmax.com/junitmax/subscribe.html + +Example: + + public static class TwoUnEqualTests { @Test public void slow() throws InterruptedException { Thread.sleep(100); @@ -94,3 +94,7 @@ API. In 4.6, the filter that implements this is exposed as `Filter.matchDescrip - Added how to run JUnit from the command line to the cookbook. - junit-4.x.zip now contains build.xml + +### Bug fixes ### +- Fixed overly permissive @DataPoint processing (2191102) +- Fixed bug in test counting after an ignored method (2106324) diff --git a/doc/markdown.sh b/doc/markdown.sh index dbef13ed6c7e..d6b17713c876 100644 --- a/doc/markdown.sh +++ b/doc/markdown.sh @@ -1 +1 @@ -~/bin/Markdown.pl ReleaseNotes4.4.txt >ReleaseNotes4.4.html \ No newline at end of file +~/bin/Markdown.pl ReleaseNotes4.6.txt >ReleaseNotes4.6.html \ No newline at end of file diff --git a/src/main/java/junit/runner/Version.java b/src/main/java/junit/runner/Version.java index d3235a96048c..33dba808d89d 100644 --- a/src/main/java/junit/runner/Version.java +++ b/src/main/java/junit/runner/Version.java @@ -9,7 +9,7 @@ private Version() { } public static String id() { - return "4.5"; + return "4.6-RC1"; } public static void main(String[] args) { diff --git a/src/main/java/org/junit/Assert.java b/src/main/java/org/junit/Assert.java index 370b43859904..11f43736718d 100644 --- a/src/main/java/org/junit/Assert.java +++ b/src/main/java/org/junit/Assert.java @@ -364,6 +364,37 @@ public static void assertArrayEquals(double[] expecteds, double[] actuals, doubl assertArrayEquals(null, expecteds, actuals, delta); } + /** + * Asserts that two double arrays are equal. If they are not, an + * {@link AssertionError} is thrown with the given message. + * + * @param message + * the identifying message for the {@link AssertionError} (null + * okay) + * @param expecteds + * double array with expected values. + * @param actuals + * double array with actual values + */ + public static void assertArrayEquals(String message, float[] expecteds, + float[] actuals, float delta) throws ArrayComparisonFailure { + new InexactComparisonCriteria(delta).internalArrayEquals(message, expecteds, actuals); + } + + // TODO (Mar 10, 2009 10:52:18 AM): fix javadoc + /** + * Asserts that two double arrays are equal. If they are not, an + * {@link AssertionError} is thrown. + * + * @param expecteds + * double array with expected values. + * @param actuals + * double array with actual values + */ + public static void assertArrayEquals(float[] expecteds, float[] actuals, float delta) { + assertArrayEquals(null, expecteds, actuals, delta); + } + /** * Asserts that two object arrays are equal. If they are not, an * {@link AssertionError} is thrown with the given message. If diff --git a/src/main/java/org/junit/experimental/max/MaxCore.java b/src/main/java/org/junit/experimental/max/MaxCore.java index 4eaa178d5015..7592e51fe18b 100644 --- a/src/main/java/org/junit/experimental/max/MaxCore.java +++ b/src/main/java/org/junit/experimental/max/MaxCore.java @@ -18,6 +18,10 @@ import org.junit.runners.model.InitializationError; public class MaxCore { + public static MaxCore forFolder(String fileName) { + return storedLocally(new File(fileName)); + } + public static MaxCore storedLocally(File storedResults) { return new MaxCore(storedResults); } diff --git a/src/main/java/org/junit/internal/InexactComparisonCriteria.java b/src/main/java/org/junit/internal/InexactComparisonCriteria.java index 11e844f260bc..0b7cf72158be 100644 --- a/src/main/java/org/junit/internal/InexactComparisonCriteria.java +++ b/src/main/java/org/junit/internal/InexactComparisonCriteria.java @@ -59,7 +59,10 @@ public void internalArrayEquals(String message, Object expecteds, } } else try { - Assert.assertEquals((Double)expected, (Double)actual, fDelta); + if (expected instanceof Double) + Assert.assertEquals((Double)expected, (Double)actual, fDelta); + else + Assert.assertEquals((Float)expected, (Float)actual, fDelta); } catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); } diff --git a/src/test/java/org/junit/tests/assertion/AssertionTest.java b/src/test/java/org/junit/tests/assertion/AssertionTest.java index 5a3676230fe7..3d6730d5812e 100644 --- a/src/test/java/org/junit/tests/assertion/AssertionTest.java +++ b/src/test/java/org/junit/tests/assertion/AssertionTest.java @@ -121,16 +121,21 @@ public void oneDimensionalPrimitiveArraysAreEqual() { assertArrayEquals(new short[] {1}, new short[] {1}); assertArrayEquals(new int[] {1}, new int[] {1}); assertArrayEquals(new long[] {1}, new long[] {1}); - // TODO: add floats assertArrayEquals(new double[] {1.0}, new double[] {1.0}, 1.0); + // TODO (Mar 10, 2009 10:47:34 AM): Import + Assert.assertArrayEquals(new float[] {1.0f}, new float[] {1.0f}, 1.0f); } @Test(expected=AssertionError.class) public void oneDimensionalDoubleArraysAreNotEqual() { - // TODO: add floats assertArrayEquals(new double[] {1.0}, new double[] {2.5}, 1.0); } + @Test(expected=AssertionError.class) + public void oneDimensionalFloatArraysAreNotEqual() { + assertArrayEquals(new float[] {1.0f}, new float[] {2.5f}, 1.0f); + } + @Test(expected=AssertionError.class) public void IntegerDoesNotEqualLong() { assertEquals(new Integer(1), new Long(1));