Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 672 lines (547 sloc) 27.126 kb
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
b6a0693 Initial revision
egamma authored
2 <html>
3 <head>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
168fe08 Final changes for release
kbeck authored
5 <meta name="Author" content="Erich Gamma, Kent Beck, and David Saff">
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
6 <title>JUnit 4.6</title>
b6a0693 Initial revision
egamma authored
7 </head>
8 <body>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
9
b6a0693 Initial revision
egamma authored
10 <h1>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
11 <b><font color="#00CC00">J</font><font color="#FF0000">U</font><font color="#000000">nit
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
12 4.6</b></h1>
168fe08 Final changes for release
kbeck authored
13 <br>Brought to you by <a href="http://www.threeriversinstitute.org">Kent Beck</a>, Erich
8ce9b2f Updated David's website
dsaff authored
14 Gamma, and <a href="http://david.saff.net">David Saff</a>.
168fe08 Final changes for release
kbeck authored
15 <br>FAQ edited by <a href="http://www.clarkware.com">Mike Clark</a>. Web mastering by Erik
16 Meade.
17 <br>(see also <a href="http://www.junit.org">JUnit.org</a>)
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
18
19 <hr WIDTH="100%">
68e5927 Last changes with Kent.
David Saff authored
20 <br>6 April 2009
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
21 <p>JUnit is a simple framework to write repeatable tests. It is an instance
22 of the xUnit architecture for unit testing frameworks.
23 <ul>
24 <li>
25 <a href="#Summary of">Summary of Changes</a></li>
26
27 <li>
28 <a href="#Contents">Contents</a></li>
29
30 <li>
31 <a href="#Installation">Installation</a></li>
32
33 <li>
34 <a href="#Getting">Getting Started</a></li>
35
36 <li>
37 <a href="#Documentation">Documentation</a></li>
168fe08 Final changes for release
kbeck authored
38 <li>
39 <a href="#Known Defects">Known Defects</a></li>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
40 </ul>
41
0096ac6 Change version number and dates
dsaff authored
42 <a NAME="Summary of">
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
43 <h2>Summary of Changes in version 4.6</h2>
7352be8 Trying to explain assertThat as a new feature
dsaff authored
44
68e5927 Last changes with Kent.
David Saff authored
45 <h3>Max</h3>
46
47 <p>JUnit now includes a new experimental Core, <code>MaxCore</code>. <code>MaxCore</code>
48 remembers the results of previous test runs in order to run new
49 tests out of order. <code>MaxCore</code> prefers new tests to old tests, fast
50 tests to slow tests, and recently failing tests to tests that last
51 failed long ago. There's currently not a standard UI for running
52 <code>MaxCore</code> included in JUnit, but there is a UI included in the JUnit
53 Max Eclipse plug-in at:</p>
54
55 <p>http://www.junitmax.com/junitmax/subscribe.html</p>
56
57 <p>Example:</p>
58
59 <pre><code>public static class TwoUnEqualTests {
60 @Test
61 public void slow() throws InterruptedException {
62 Thread.sleep(100);
63 fail();
64 }
65
66 @Test
67 public void fast() {
68 fail();
69 }
70 }
71
72 @Test
73 public void rememberOldRuns() {
74 File maxFile = new File("history.max");
75 MaxCore firstMax = MaxCore.storedLocally(maxFile);
76 firstMax.run(TwoUnEqualTests.class);
77
78 MaxCore useHistory= MaxCore.storedLocally(maxFile);
79 List&lt;Failure&gt; failures= useHistory.run(TwoUnEqualTests.class)
80 .getFailures();
81 assertEquals("fast", failures.get(0).getDescription().getMethodName());
82 assertEquals("slow", failures.get(1).getDescription().getMethodName());
83 }
84 </code></pre>
85
86 <h3>Test scheduling strategies</h3>
87
88 <p><code>JUnitCore</code> now includes an experimental method that allows you to
89 specify a model of the <code>Computer</code> that runs your tests. Currently,
90 the only built-in Computers are the default, serial runner, and two
91 runners provided in the <code>ParallelRunner</code> class:
92 <code>ParallelRunner.classes()</code>, which runs classes in parallel, and
93 <code>ParallelRunner.methods()</code>, which runs classes and methods in parallel.</p>
94
95 <p>This feature is currently less stable than MaxCore, and may be
96 merged with MaxCore in some way in the future.</p>
97
98 <p>Example:</p>
99
100 <pre><code>public static class Example {
101 @Test public void one() throws InterruptedException {
102 Thread.sleep(1000);
103 }
104 @Test public void two() throws InterruptedException {
105 Thread.sleep(1000);
106 }
107 }
108
109 @Test public void testsRunInParallel() {
110 long start= System.currentTimeMillis();
111 Result result= JUnitCore.runClasses(ParallelComputer.methods(),
112 Example.class);
113 assertTrue(result.wasSuccessful());
114 long end= System.currentTimeMillis();
115 assertThat(end - start, betweenInclusive(1000, 1500));
116 }
117 </code></pre>
118
119 <h3>Comparing double arrays</h3>
120
121 <p>Arrays of doubles can be compared, using a delta allowance for equality:</p>
122
123 <pre><code>@Test
124 public void doubleArraysAreEqual() {
125 assertArrayEquals(new double[] {1.0, 2.0}, new double[] {1.0, 2.0}, 0.01);
126 }
127 </code></pre>
128
129 <h3><code>Filter.matchDescription</code> API</h3>
130
131 <p>Since 4.0, it has been possible to run a single method using the <code>Request.method</code>
132 API. In 4.6, the filter that implements this is exposed as <code>Filter.matchDescription</code>.</p>
133
134 <h3>Documentation</h3>
135
136 <ul>
137 <li><p>A couple classes and packages that once had empty javadoc have been
138 doc'ed.</p></li>
139 <li><p>Added how to run JUnit from the command line to the cookbook.</p></li>
140 <li><p>junit-4.x.zip now contains build.xml</p></li>
141 </ul>
142
143 <h3>Bug fixes</h3>
144
145 <ul>
146 <li>Fixed overly permissive @DataPoint processing (2191102)</li>
147 <li>Fixed bug in test counting after an ignored method (2106324)</li>
148 </ul>
149
150 <h2>Summary of Changes in version 4.5</h2>
151
7e77e49 Updated README.html
dsaff authored
152 <h3>Installation</h3>
153
154 <ul>
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
155 <li>We are releasing <code>junit-4.6.jar</code>, which contains all the classes
156 necessary to run JUnit, and <code>junit-dep-4.6.jar</code>, which leaves out
7e77e49 Updated README.html
dsaff authored
157 hamcrest classes, for developers who already use hamcrest outside of
158 JUnit.</li>
159 </ul>
160
161 <h3>Basic JUnit operation</h3>
162
163 <ul>
164 <li><p>JUnitCore now more often exits with the correct exit code (0 for
165 success, 1 for failure)</p></li>
166 <li><p>Badly formed test classes (exceptions in constructors, classes
167 without tests, multiple constructors, Suite without @SuiteClasses)
168 produce more helpful error messages</p></li>
169 <li><p>Test classes whose only test methods are inherited from superclasses
170 now run.</p></li>
171 <li><p>Optimization to annotation processing can cut JUnit overhead by more than half
172 on large test classes, especially when using Theories. [Bug 1796847]</p></li>
173 <li><p>A failing assumption in a constructor ignores the class</p></li>
174 <li><p>Correct results when comparing the string "null" with potentially
175 null values. [Bug 1857283]</p></li>
176 <li><p>Annotating a class with <code>@RunWith(JUnit4.class)</code> will always invoke the
177 default JUnit 4 runner in the current version of JUnit. This default changed
178 from <code>JUnit4ClassRunner</code> in 4.4 to <code>BlockJUnit4ClassRunner</code> in 4.5 (see below),
179 and may change again.</p></li>
180 </ul>
181
182 <h3>Extension</h3>
183
184 <ul>
185 <li><p><code>BlockJUnit4Runner</code> is a new implementation of the standard JUnit 4
186 test class functionality. In contrast to <code>JUnit4ClassRunner</code> (the old
187 implementation):</p>
188
189 <ul>
190 <li><p><code>BlockJUnit4Runner</code> has a much simpler implementation based on
191 Statements, allowing new operations to be inserted into the
192 appropriate point in the execution flow.</p></li>
193 <li><p><code>BlockJUnit4Runner</code> is published, and extension and reuse are
194 encouraged, whereas <code>JUnit4ClassRunner</code> was in an internal package,
195 and is now deprecated.</p></li>
196 </ul></li>
197 <li><p><code>ParentRunner</code> is a base class for runners that iterate over
198 a list of "children", each an object representing a test or suite to run.
199 <code>ParentRunner</code> provides filtering, sorting, <code>@BeforeClass</code>, <code>@AfterClass</code>,
200 and method validation to subclasses.</p></li>
201 <li><p><code>TestClass</code> wraps a class to be run, providing efficient, repeated access
202 to all methods with a given annotation.</p></li>
203 <li><p>The new <code>RunnerBuilder</code> API allows extending the behavior of
204 Suite-like custom runners.</p></li>
205 <li><p><code>AssumptionViolatedException.toString()</code> is more informative</p></li>
206 </ul>
207
208 <h3>Extra Runners</h3>
209
210 <ul>
211 <li><p><code>Parameterized.eachOne()</code> has been removed</p></li>
212 <li><p>New runner <code>Enclosed</code> runs all static inner classes of an outer class.</p></li>
213 </ul>
214
215 <h3>Theories</h3>
216
217 <ul>
218 <li><p><code>@Before</code> and <code>@After</code> methods are run before and after each set of attempted parameters
219 on a Theory, and each set of parameters is run on a new instance of the test class.</p></li>
220 <li><p>Exposed API's <code>ParameterSignature.getType()</code> and <code>ParameterSignature.getAnnotations()</code></p></li>
221 <li><p>An array of data points can be introduced by a field or method
222 marked with the new annotation <code>@DataPoints</code></p></li>
223 <li><p>The Theories custom runner has been refactored to make it faster and
224 easier to extend</p></li>
225 </ul>
226
227 <h3>Development</h3>
228
229 <ul>
230 <li><p>Source has been split into directories <code>src/main/java</code> and
231 <code>src/test/java</code>, making it easier to exclude tests from builds, and
232 making JUnit more maven-friendly</p></li>
233 <li><p>Test classes in <code>org.junit.tests</code> have been organized into
234 subpackages, hopefully making finding tests easier.</p></li>
235 <li><p><code>ResultMatchers</code> has more informative descriptions.</p></li>
236 <li><p><code>TestSystem</code> allows testing return codes and other system-level interactions.</p></li>
237 </ul>
238
239 <h2>Summary of Changes in version 4.4</h2>
240
0096ac6 Change version number and dates
dsaff authored
241 <p>JUnit is designed to efficiently capture developers' intentions about
242 their code, and quickly check their code matches those intentions.
243 Over the last year, we've been talking about what things developers
244 would like to say about their code that have been difficult in the
245 past, and how we can make them easier.</p>
7352be8 Trying to explain assertThat as a new feature
dsaff authored
246
0096ac6 Change version number and dates
dsaff authored
247 <h3>assertThat</h3>
7352be8 Trying to explain assertThat as a new feature
dsaff authored
248
0096ac6 Change version number and dates
dsaff authored
249 <p>Two years ago, Joe Walnes built a <a href="http://joe.truemesh.com/blog/000511.html">new assertion mechanism</a> on top of what was
250 then <a href="http://www.jmock.org/download.html">JMock 1</a>. The method name was <code>assertThat</code>, and the syntax looked like this:</p>
251
252 <pre><code>assertThat(x, is(3));
7352be8 Trying to explain assertThat as a new feature
dsaff authored
253 assertThat(x, is(not(4)));
0096ac6 Change version number and dates
dsaff authored
254 assertThat(responseString, either(containsString("color")).or(containsString("colour")));
7352be8 Trying to explain assertThat as a new feature
dsaff authored
255 assertThat(myList, hasItem("3"));
0096ac6 Change version number and dates
dsaff authored
256 </code></pre>
7352be8 Trying to explain assertThat as a new feature
dsaff authored
257
0096ac6 Change version number and dates
dsaff authored
258 <p>More generally:</p>
7352be8 Trying to explain assertThat as a new feature
dsaff authored
259
0096ac6 Change version number and dates
dsaff authored
260 <pre><code>assertThat([value], [matcher statement]);
261 </code></pre>
262
263 <p>Advantages of this assertion syntax include:</p>
7352be8 Trying to explain assertThat as a new feature
dsaff authored
264
265 <ul>
0096ac6 Change version number and dates
dsaff authored
266 <li><p>More readable and typeable: this syntax allows you to think in terms of subject, verb, object
267 (assert "x is 3") rathern than <code>assertEquals</code>, which uses verb, object, subject (assert "equals 3 x")</p></li>
268 <li><p>Combinations: any matcher statement <code>s</code> can be negated (<code>not(s)</code>), combined (<code>either(s).or(t)</code>),
269 mapped to a collection (<code>each(s)</code>), or used in custom combinations (<code>afterFiveSeconds(s)</code>)</p></li>
270 <li><p>Readable failure messages. Compare</p>
271
272 <pre><code>assertTrue(responseString.contains("color") || responseString.contains("colour"));
273 // ==&gt; failure message:
274 // java.lang.AssertionError:
275
276
277 assertThat(responseString, anyOf(containsString("color"), containsString("colour")));
278 // ==&gt; failure message:
279 // java.lang.AssertionError:
280 // Expected: (a string containing "color" or a string containing "colour")
281 // got: "Please choose a font"
282 </code></pre></li>
283 <li><p>Custom Matchers. By implementing the <code>Matcher</code> interface yourself, you can get all of the
284 above benefits for your own custom assertions.</p></li>
285 <li><p>For a more thorough description of these points, see <a href="http://joe.truemesh.com/blog/000511.html">Joe Walnes's
286 original post</a>.:</p></li>
7352be8 Trying to explain assertThat as a new feature
dsaff authored
287 </ul>
4589995 Added both(matcher).and(matcher)
dsaff authored
288
0096ac6 Change version number and dates
dsaff authored
289 <p>We have decided to include this API directly in JUnit.
290 It's an extensible and readable syntax, and because it enables
291 new features, like <a href="#assumptions">assumptions</a> and <a href="#theories">theories</a>.</p>
292
293 <p>Some notes:</p>
294
295 <ul>
296 <li>The old assert methods are never, ever, going away. <br />
297 Developers may continue using the old <code>assertEquals</code>, <code>assertTrue</code>, and
298 so on.</li>
299 <li><p>The second parameter of an <code>assertThat</code> statement is a <code>Matcher</code>.
300 We include the Matchers we want as static imports, like this:</p>
301
302 <pre><code>import static org.hamcrest.CoreMatchers.is;
303 </code></pre>
304
305 <p>or:</p>
306
307 <pre><code>import static org.hamcrest.CoreMatchers.*;
308 </code></pre></li>
309 <li><p>Manually importing <code>Matcher</code> methods can be frustrating. [Eclipse
310 3.3][] includes the ability to
311 define
312 "Favorite" classes to import static methods from, which makes it easier
313 (Search for "Favorites" in the Preferences dialog).
314 We expect that support for static imports will improve in all Java IDEs in the future.</p></li>
315 <li><p>To allow compatibility with a wide variety of possible matchers,
316 we have decided to include the classes from hamcrest-core,
317 from the <a href="http://code.google.com/p/hamcrest/">Hamcrest</a> project. This is the first time that
318 third-party classes have been included in JUnit. </p></li>
8bed6c9 - Moved InitializationError to ParentRunner, since it was only used by
dsaff authored
319 <li><p>To allow developers to maintain full control of the classpath contents, the JUnit distribution also provides an unbundled junit-dep jar,
320 ie without hamcrest-core classes included. This is intended for situations when using other libraries that also depend on hamcrest-core, to
321 avoid classloading conflicts or issues. Developers using junit-dep should ensure a compatible version of hamcrest-core jar (ie 1.1+) is present in the classpath.</p></li>
0096ac6 Change version number and dates
dsaff authored
322 <li><p>JUnit currently ships with a few matchers, defined in
323 <code>org.hamcrest.CoreMatchers</code> and <code>org.junit.matchers.JUnitMatchers</code>. <br />
324 To use many, many more, consider downloading the <a href="http://hamcrest.googlecode.com/files/hamcrest-all-1.1.jar">full hamcrest package</a>.</p></li>
325 <li><p>JUnit contains special support for comparing string and array
326 values, giving specific information on how they differ. This is not
327 yet available using the <code>assertThat</code> syntax, but we hope to bring
328 the two assert methods into closer alignment in future releases.</p></li>
329 </ul>
330
331 <h3>assumeThat</h3>
332
333 <p><a name="assumptions" />
334 Ideally, the developer writing a test has control of all of the forces that might cause a test to fail.
335 If this isn't immediately possible, making dependencies explicit can often improve a design. <br />
336 For example, if a test fails when run in a different locale than the developer intended,
337 it can be fixed by explicitly passing a locale to the domain code.</p>
338
339 <p>However, sometimes this is not desirable or possible. <br />
340 It's good to be able to run a test against the code as it is currently written,
341 implicit assumptions and all, or to write a test that exposes a known bug.
342 For these situations, JUnit now includes the ability to express "assumptions":</p>
343
344 <pre><code>import static org.junit.Assume.*
345
4589995 Added both(matcher).and(matcher)
dsaff authored
346 @Test public void filenameIncludesUsername() {
347 assumeThat(File.separatorChar, is('/'));
0096ac6 Change version number and dates
dsaff authored
348 assertThat(new User("optimus").configFileName(), is("configfiles/optimus.cfg"));
4589995 Added both(matcher).and(matcher)
dsaff authored
349 }
350
351 @Test public void correctBehaviorWhenFilenameIsNull() {
352 assumeTrue(bugFixed("13356")); // bugFixed is not included in JUnit
353 assertThat(parse(null), is(new NullDocument()));
354 }
0096ac6 Change version number and dates
dsaff authored
355 </code></pre>
356
357 <p>With this beta release, a failed assumption will lead to the test being marked as passing,
358 regardless of what the code below the assumption may assert.
359 In the future, this may change, and a failed assumption may lead to the test being ignored:
360 however, third-party runners do not currently allow this option.</p>
361
362 <p>We have included <code>assumeTrue</code> for convenience, but thanks to the
363 inclusion of Hamcrest, we do not need to create <code>assumeEquals</code>,
364 <code>assumeSame</code>, and other analogues to the <code>assert*</code> methods. All of
365 those functionalities are subsumed in assumeThat, with the appropriate
366 matcher.</p>
367
85c570e Failed assumptions in @Before and @BeforeClass cause the test to pass
dsaff authored
368 <p>A failing assumption in a <code>@Before</code> or <code>@BeforeClass</code> method will have the same effect
369 as a failing assumption in each <code>@Test</code> method of the class.</p>
370
0096ac6 Change version number and dates
dsaff authored
371 <h3>Theories</h3>
372
373 <p><a name="theories" />
374 More flexible and expressive assertions, combined with the ability to
375 state assumptions clearly, lead to a new kind of statement of intent,
376 which we call a "Theory". A test captures the intended behavior in
377 one particular scenario. A theory allows a developer to be
378 as precise as desired about the behavior of the code in possibly
379 infinite numbers of possible scenarios. For example:</p>
380
381 <pre><code>@RunWith(Theories.class)
382 public class UserTest {
383 @DataPoint public static String GOOD_USERNAME = "optimus";
384 @DataPoint public static String USERNAME_WITH_SLASH = "optimus/prime";
385
386 @Theory public void filenameIncludesUsername(String username) {
387 assumeThat(username, not(containsString("/")));
388 assertThat(new User(username).configFileName(), containsString(username));
389 }
390 }
391 </code></pre>
392
393 <p>This makes it clear that the user's filename should be included in the
394 config file name, only if it doesn't contain a slash. Another test
395 or theory might define what happens when a username does contain a slash.</p>
396
397 <p><code>UserTest</code> will attempt to run <code>filenameIncludesUsername</code> on
398 every compatible <code>DataPoint</code> defined in the class. If any of the
399 assumptions fail, the data point is silently ignored. If all of the
400 assumptions pass, but an assertion fails, the test fails.</p>
401
402 <p>The support for Theories has been absorbed from the <a href="http://popper.tigris.org">Popper</a>
403 project, and <a href="http://popper.tigris.org/tutorial.html">more complete documentation</a> can be found
404 there.</p>
405
406 <p>Defining general statements in this way can jog the developer's memory
407 about other potential data points and tests, also allows <a href="http://www.junitfactory.org">automated
408 tools</a> to <a href="http://shareandenjoy.saff.net/2007/04/popper-and-junitfactory.html">search</a> for new, unexpected data
409 points that expose bugs.</p>
410
411 <h3>Other changes</h3>
412
413 <p>This release contains other bug fixes and new features. Among them:</p>
414
415 <ul>
416 <li><p>Annotated descriptions</p>
417
418 <p>Runner UIs, Filters, and Sorters operate on Descriptions of test
419 methods and test classes. These Descriptions now include the
420 annotations on the original Java source element, allowing for richer
421 display of test results, and easier development of annotation-based
422 filters.</p></li>
423 <li><p>Bug fix (1715326): assertEquals now compares all Numbers using their
424 native implementation of <code>equals</code>. This assertion, which passed in
425 4.3, will now fail:</p>
426
427 <p>assertEquals(new Integer(1), new Long(1));</p>
428
429 <p>Non-integer Numbers (Floats, Doubles, BigDecimals, etc),
430 which were compared incorrectly in 4.3, are now fixed.</p></li>
431 <li><p><code>assertEquals(long, long)</code> and <code>assertEquals(double, double)</code> have
432 been re-introduced to the <code>Assert</code> class, to take advantage of
433 Java's native widening conversions. Therefore, this still passes:</p>
434
435 <p>assertEquals(1, 1L);</p></li>
436 <li><p>The default runner for JUnit 4 test classes has been refactored.
437 The old version was named <code>TestClassRunner</code>, and the new is named
438 <code>JUnit4ClassRunner</code>. Likewise, <code>OldTestClassRunner</code> is now
439 <code>JUnit3ClassRunner</code>. The new design allows variations in running
440 individual test classes to be expressed with fewer custom classes.
441 For a good example, see the source to
85c570e Failed assumptions in @Before and @BeforeClass cause the test to pass
dsaff authored
442 <code>org.junit.experimental.theories.Theories</code>.</p></li>
0096ac6 Change version number and dates
dsaff authored
443 <li><p>The rules for determining which runner is applied by default to a
444 test class have been simplified:</p>
445
446 <ol>
447 <li><p>If the class has a <code>@RunWith</code> annotation, the annotated runner
448 class is used.</p></li>
449 <li><p>If the class can be run with the JUnit 3 test runner (it
450 subclasses <code>TestCase</code>, or contains a <code>public static Test suite()</code>
451 method), JUnit38ClassRunner is used.</p></li>
452 <li><p>Otherwise, JUnit4ClassRunner is used.</p></li>
453 </ol>
454
455 <p>This default guess can always be overridden by an explicit
456 <code>@RunWith(JUnit4ClassRunner.class)</code> or
457 <code>@RunWith(JUnit38ClassRunner.class)</code> annotation.</p>
458
459 <p>The old class names <code>TestClassRunner</code> and <code>OldTestClassRunner</code>
460 remain as deprecated.</p></li>
461 <li><p>Bug fix (1739095): Filters and Sorters work correctly on test
462 classes that contain a <code>suite</code> method like:</p>
463
464 <p>public static junit.framework.Test suite() {
465 return new JUnit4TestAdapter(MyTest.class);
466 }</p></li>
467 <li><p>Bug fix (1745048): @After methods are now correctly called
468 after a test method times out.</p></li>
469 </ul>
7352be8 Trying to explain assertThat as a new feature
dsaff authored
470
471 <h2>
e8a2d8e Merge build script with 4.3.1
dsaff authored
472 <a NAME="Summary of"></a>Summary of Changes in version 4.3.1</h2>
473 <p>
474 <ul>
475 <li>Bug fix: 4.3 introduced a
476 <a href="https://sourceforge.net/tracker/?func=detail&atid=115278&aid=1684562&group_id=15278">bug</a>
477 that caused a NullPointerException
478 when comparing a null reference to a non-null reference in <tt>assertEquals</tt>.
479 This has been fixed.
480 <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,
481 which are now removed for a smaller download, but, as always, available from the
482 full zip.
483 </ul>
484 </p>
485
486 <h2>
121f283 Moving version number up to 4.3
dsaff authored
487 <a NAME="Summary of"></a>Summary of Changes with version 4.3</h2>
488 <p>
489 <ul>
490 <li>Changes in array equality. Using <tt>assertEquals</tt> to compare array contents is now deprecated.
491 In the future, <tt>assertEquals</tt> will revert to its pre-4.0 meaning of comparing objects based on
492 Java's <tt>Object.equals</tt> semantics. To compare array contents, use the new, more reliable
493 <tt>Assert.assertArrayEquals</tt> methods.
494 <li>The <tt>@Ignore</tt> annotation can now be applied to classes, to ignore the entire class, instead of
495 individual methods.
496 <li>Originally, developers who wanted to use a static <tt>suite()</tt> method from JUnit 3.x with a JUnit 4.x
497 runner had to annotate the class with <tt>@RunWith(AllTests.class)</tt>. In the common case, this requirement
498 has been removed. However, when such a class is wrapped with a JUnit4TestAdapter (which we believe is rare), the
499 results may not be as expected.
500 <li>Improved error messages for array comparison("arrays first differed at element [1][0]")
501 <li>Bug fix: Inaccessible base class is caught at test construction time.
502 <li>Bug fix: Circular suites are caught at test construction time.
503 <li>Bug fix: Test constructors that throw exceptions are reported correctly.
504 <li><b>For committers and extenders</b>
505 <ul>
506 <li>Sources now are in a separate "src" directory (this means a big break in the CVS history)
507 <li>Improved documentation in <tt>Request</tt>, <tt>RunWith</tt>
508 </ul>
509 </ul>
510 </p>
511
512 <h2>
0cdf297 - Fixed raw types because Eclipse 3.3 told us to.
dsaff authored
513 <a NAME="Summary of"></a>Summary of Changes with version 4.2</h2>
514 <p>
515 <ul>
516 <li>Bug fix: Inaccessible base class is caught at test construction time.
517 <li>Bug fix: Circular suites are caught at test construction time.
518 <li>Improved error messages for array comparison("arrays first differed at element [1][0]")
519 <li>Test constructors that throw exceptions are reported correctly.
520 </ul>
521 </p>
522
523
524 <h2>
42ed30e README up to date for 4.1
dsaff authored
525 <a NAME="Summary of"></a>Summary of Changes with version 4.1</h2>
526 <p>
527 <ul>
528 <li>Bug fix: listeners now get a correct test running time, rather than always being told 0 secs.
529 <li>The @RunWith annotation is now inherited by subclasses:
530 all subclasses of an abstract test class will be run by the same runner.
531 <li>The build script fails if the JUnit unit tests fail
532 <li>The faq has been updated
533 <li>Javadoc has been improved, with more internal links, and package descriptions added (Thanks, Matthias Schmidt!)
534 <li>An acknowledgements.txt file has been created to credit outside contributions
57f0690 Updated README about Enclosed
dsaff authored
535 <li>The <tt>Enclosed</tt> runner, which runs all of the static inner classes of a given class, has been added
536 to <tt>org.junit.runners</tt>.
42ed30e README up to date for 4.1
dsaff authored
537 </ul>
538 </p>
539
540 <h2>Summary of Changes with version 4.0</h2>
168fe08 Final changes for release
kbeck authored
541 <p>
542 The architecture of JUnit 4.0 is a substantial departure from that of earlier releases.
543 Instead of
544 tagging test classes by subclassing junit.framework.TestCase and tagging test methods by
545 starting their name with "test", you now tag test methods with the @Test annotation.
546 </p>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
547
548
a24fe64 backed out calling setContextClassLoader on the test thread
egamma authored
549 <h2>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
550 <a NAME="Contents"></a>Contents of the Release</h2>
551
552 <table CELLSPACING=0 CELLPADDING=0 >
553 <tr>
554 <td><tt>README.html&nbsp;</tt></td>
555
556 <td>this file</td>
557 </tr>
558
559 <tr>
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
560 <td><tt>junit-4.6.jar</tt></td>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
561
8bed6c9 - Moved InitializationError to ParentRunner, since it was only used by
dsaff authored
562 <td>a jar file with the JUnit framework, bundled with the hamcrest-core-1.1 dependency.</td>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
563 </tr>
564
565 <tr>
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
566 <td><tt>junit-dep-4.6.jar</tt></td>
8bed6c9 - Moved InitializationError to ParentRunner, since it was only used by
dsaff authored
567
568 <td>a jar file with the JUnit framework, unbundled from any external dependencies.
569 Choosing to use this jar developers will need to also provide in the classpath a compatible version of external dependencies (ie hamcrest-core-1.1+)</td>
570 </tr>
571
572 <tr>
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
573 <td><tt>junit-4.6-src.jar</tt></td>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
574
168fe08 Final changes for release
kbeck authored
575 <td>a jar file with the source code of the JUnit framework</td>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
576 </tr>
577
578 <tr>
168fe08 Final changes for release
kbeck authored
579 <td><tt>org/junit</tt></td>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
580
168fe08 Final changes for release
kbeck authored
581 <td>the source code of the basic JUnit annotations and classes</td>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
582 </tr>
583
584 <tr>
585 <td><tt>&nbsp;&nbsp;&nbsp; samples</tt></td>
586
587 <td>sample test cases</td>
588 </tr>
589
590 <tr>
591 <td><tt>&nbsp;&nbsp;&nbsp; tests</tt></td>
592
593 <td>test cases for JUnit itself</td>
594 </tr>
595
596 <tr>
597 <td><tt>javadoc</tt></td>
598
599 <td>javadoc generated documentation</td>
600 </tr>
601
602 <tr>
603 <td><tt>doc</tt></td>
604
605 <td>documentation and articles</td>
606 </tr>
b6a0693 Initial revision
egamma authored
607 </table>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
608
b6a0693 Initial revision
egamma authored
609 <h2>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
610 <a NAME="Installation"></a>Installation</h2>
611 Below are the installation steps for installing JUnit:
b6a0693 Initial revision
egamma authored
612 <ol>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
613 <li>
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
614 unzip the junit4.6.zip file</li>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
615
616 <li>
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
617 add<i> </i><b>junit-4.6.jar</b> to the CLASSPATH. For example:
618 <tt> set classpath=%classpath%;INSTALL_DIR\junit-4.6.jar;INSTALL_DIR</tt></li>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
619
620 <li>
60f3a3f Remove a period, pursuant to bug 2768146
David Saff authored
621 test the installation by running <tt>java org.junit.runner.JUnitCore org.junit.tests.AllTests</tt></li>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
622
623 <br><b><font color="#FF0000">Notice</font></b>: that the tests are not
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
624 contained in the junit-4.6.jar but in the installation directory directly.
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
625 Therefore make sure that the installation directory is on the class path
b6a0693 Initial revision
egamma authored
626 </ol>
1c1a6f8 Tagged old version as 4.5. Docs now say 4.6, and doc'ed a few missing c...
dsaff authored
627 <b><font color="#FF0000">Important</font></b>: don't install junit-4.6.jar
4b1869e JUnit 3.5 candidate
egamma authored
628 into the extension directory of your JDK installation. If you do so the
629 test class on the files system will not be found.
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
630 <h2>
631 <a NAME="Getting"></a>Getting Started</h2>
168fe08 Final changes for release
kbeck authored
632 To get started with unit testing and JUnit read the article:
633 <a href="doc/cookbook/cookbook.htm">JUnit Cookbook</a>.
634 <br>This article describes basic test writing using JUnit 4.
42ed30e README up to date for 4.1
dsaff authored
635 <p>You find additional samples in the org.junit.samples package:
b6a0693 Initial revision
egamma authored
636 <ul>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
637 <li>
638 SimpleTest.java - some simple test cases</li>
639
640 <li>
641 VectorTest.java - test cases for java.util.Vector</li>
b6a0693 Initial revision
egamma authored
642 </ul>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
643
b6a0693 Initial revision
egamma authored
644 <h2>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
645 <a NAME="Documentation"></a>Documentation</h2>
646
647 <blockquote><a href="doc/cookbook/cookbook.htm">JUnit Cookbook</a>
648 <br>&nbsp;&nbsp;&nbsp; A cookbook for implementing tests with JUnit.
168fe08 Final changes for release
kbeck authored
649 <br><a href="javadoc/index.html">Javadoc</a>
650 <br>&nbsp;&nbsp;&nbsp; API documentation generated with javadoc.
651 <br><a href="doc/faq/faq.htm">Frequently asked questions</a>
652 <br>&nbsp;&nbsp;&nbsp; Some frequently asked questions about using JUnit.
653 <br><a href="cpl-v10.html">License</a>
654 <br>&nbsp;&nbsp;&nbsp; The terms of the common public license used for JUnit.<br>
655 </blockquote>
656 The following documents still describe JUnit 3.8.
657 <blockquote>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
658 <br><a href="doc/testinfected/testing.htm">Test Infected - Programmers
b6a0693 Initial revision
egamma authored
659 Love Writing Tests</a>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
660 <br>&nbsp;&nbsp;&nbsp; An article demonstrating the development process
b6a0693 Initial revision
egamma authored
661 with JUnit.
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
662 <br><a href="doc/cookstour/cookstour.htm">JUnit - A cooks tour</a>
168fe08 Final changes for release
kbeck authored
663 </blockquote>
478f7f9 Merged with branch, Kent will make final changes and launch.
dsaff authored
664
665 <hr WIDTH="100%">
666 <!--webbot bot="HTMLMarkup" startspan --><a href="http://sourceforge.net"><IMG
667 src="http://sourceforge.net/sflogo.php?group_id=15278"
668 width="88" height="31" border="0" alt="SourceForge Logo"></a><!--webbot
669 bot="HTMLMarkup" endspan -->
b6a0693 Initial revision
egamma authored
670 </body>
671 </html>
Something went wrong with that request. Please try again.