Skip to content

Commit

Permalink
Last changes with Kent.
Browse files Browse the repository at this point in the history
Added fixed bugs to Release notes.
Updated version number.
Updated README.html

Signed-off-by: Kent Beck <kent@threeriversinstitute.org>
  • Loading branch information
David Saff authored and KentBeck committed Apr 7, 2009
1 parent 06d5155 commit 7098643
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README
@@ -1 +1 @@
test
Please read README.html
114 changes: 108 additions & 6 deletions README.html
Expand Up @@ -18,7 +18,7 @@ <h1>
<br>(see also <a href="http://www.junit.org">JUnit.org</a>)

<hr WIDTH="100%">
<br>[old date] 8 August 2008
<br>6 April 2009
<p>JUnit is a simple framework to write repeatable tests. It is an instance
of the xUnit architecture for unit testing frameworks.
<ul>
Expand All @@ -43,6 +43,113 @@ <h1>
<a NAME="Summary of">
<h2>Summary of Changes in version 4.6</h2>

<h3>Max</h3>

<p>JUnit now includes a new experimental Core, <code>MaxCore</code>. <code>MaxCore</code>
remembers the results of previous test runs in order to run new
tests out of order. <code>MaxCore</code> 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
<code>MaxCore</code> included in JUnit, but there is a UI included in the JUnit
Max Eclipse plug-in at:</p>

<p>http://www.junitmax.com/junitmax/subscribe.html</p>

<p>Example:</p>

<pre><code>public static class TwoUnEqualTests {
@Test
public void slow() throws InterruptedException {
Thread.sleep(100);
fail();
}

@Test
public void fast() {
fail();
}
}

@Test
public void rememberOldRuns() {
File maxFile = new File("history.max");
MaxCore firstMax = MaxCore.storedLocally(maxFile);
firstMax.run(TwoUnEqualTests.class);

MaxCore useHistory= MaxCore.storedLocally(maxFile);
List&lt;Failure&gt; failures= useHistory.run(TwoUnEqualTests.class)
.getFailures();
assertEquals("fast", failures.get(0).getDescription().getMethodName());
assertEquals("slow", failures.get(1).getDescription().getMethodName());
}
</code></pre>

<h3>Test scheduling strategies</h3>

<p><code>JUnitCore</code> now includes an experimental method that allows you to
specify a model of the <code>Computer</code> that runs your tests. Currently,
the only built-in Computers are the default, serial runner, and two
runners provided in the <code>ParallelRunner</code> class:
<code>ParallelRunner.classes()</code>, which runs classes in parallel, and
<code>ParallelRunner.methods()</code>, which runs classes and methods in parallel.</p>

<p>This feature is currently less stable than MaxCore, and may be
merged with MaxCore in some way in the future.</p>

<p>Example:</p>

<pre><code>public static class Example {
@Test public void one() throws InterruptedException {
Thread.sleep(1000);
}
@Test public void two() throws InterruptedException {
Thread.sleep(1000);
}
}

@Test public void testsRunInParallel() {
long start= System.currentTimeMillis();
Result result= JUnitCore.runClasses(ParallelComputer.methods(),
Example.class);
assertTrue(result.wasSuccessful());
long end= System.currentTimeMillis();
assertThat(end - start, betweenInclusive(1000, 1500));
}
</code></pre>

<h3>Comparing double arrays</h3>

<p>Arrays of doubles can be compared, using a delta allowance for equality:</p>

<pre><code>@Test
public void doubleArraysAreEqual() {
assertArrayEquals(new double[] {1.0, 2.0}, new double[] {1.0, 2.0}, 0.01);
}
</code></pre>

<h3><code>Filter.matchDescription</code> API</h3>

<p>Since 4.0, it has been possible to run a single method using the <code>Request.method</code>
API. In 4.6, the filter that implements this is exposed as <code>Filter.matchDescription</code>.</p>

<h3>Documentation</h3>

<ul>
<li><p>A couple classes and packages that once had empty javadoc have been
doc'ed.</p></li>
<li><p>Added how to run JUnit from the command line to the cookbook.</p></li>
<li><p>junit-4.x.zip now contains build.xml</p></li>
</ul>

<h3>Bug fixes</h3>

<ul>
<li>Fixed overly permissive @DataPoint processing (2191102)</li>
<li>Fixed bug in test counting after an ignored method (2106324)</li>
</ul>

<h2>Summary of Changes in version 4.5</h2>

<h3>Installation</h3>

<ul>
Expand Down Expand Up @@ -556,11 +663,6 @@ <h2>
<br><a href="doc/cookstour/cookstour.htm">JUnit - A cooks tour</a>
</blockquote>

<h2><a NAME="Known Defects"></a>Known Defects</h2>
<ul>
<li>Multi-dimensional arrays are not processed correctly by assertEquals.</li>
</ul>

<hr WIDTH="100%">
<!--webbot bot="HTMLMarkup" startspan --><a href="http://sourceforge.net"><IMG
src="http://sourceforge.net/sflogo.php?group_id=15278"
Expand Down
7 changes: 7 additions & 0 deletions doc/ReleaseNotes4.6.html
Expand Up @@ -97,3 +97,10 @@ <h3>Documentation</h3>
<li><p>Added how to run JUnit from the command line to the cookbook.</p></li>
<li><p>junit-4.x.zip now contains build.xml</p></li>
</ul>

<h3>Bug fixes</h3>

<ul>
<li>Fixed overly permissive @DataPoint processing (2191102)</li>
<li>Fixed bug in test counting after an ignored method (2106324)</li>
</ul>
30 changes: 17 additions & 13 deletions doc/ReleaseNotes4.6.txt
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion doc/markdown.sh
@@ -1 +1 @@
~/bin/Markdown.pl ReleaseNotes4.4.txt >ReleaseNotes4.4.html
~/bin/Markdown.pl ReleaseNotes4.6.txt >ReleaseNotes4.6.html
2 changes: 1 addition & 1 deletion src/main/java/junit/runner/Version.java
Expand Up @@ -9,7 +9,7 @@ private Version() {
}

public static String id() {
return "4.5";
return "4.6-RC1";
}

public static void main(String[] args) {
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/org/junit/Assert.java
Expand Up @@ -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} (<code>null</code>
* 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
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/junit/experimental/max/MaxCore.java
Expand Up @@ -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);
}
Expand Down
Expand Up @@ -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);
}
Expand Down
9 changes: 7 additions & 2 deletions src/test/java/org/junit/tests/assertion/AssertionTest.java
Expand Up @@ -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));
Expand Down

0 comments on commit 7098643

Please sign in to comment.