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