Preface

Table of Contents

Available formats for this document
License
Purpose
Coverage
Support
[Note]Note

In January of 2009. this document was forked off of the 3.x HOWTO, including a rewrite of 90% of the content. JUnit 4.x is clearly the way of the future. If I was new to JUnit, I wouldn't waste my time learning 3.x. Consequently, this Guide has been greatly simplified by omitting the many complex configurations supported only with JUnit 3.x.

If you notice any mistakes in this document, please email the author at blaine dot simpson at admc dot com so that he can correct them. (We require you to convert the "and"s and "dot"s with the corresponding punctuation, in order to thwart spammers). See the Support section below about any other issues.

Available formats for this document

This document is available in several formats.

[Note]Note

Standalone PDF readers (those that do not display inside of a web browser frame) can't resolve relative URLs. Therefore, if you are viewing this document with a standalone PDF reader, links to external files distributed with this document will not work.

You may be reading this document right now at http://pub.admc.com/howtos, or in a distribution somewhere else. I hereby call the document distribution from which you are reading this, your current distro.

http://pub.admc.com/howtos hosts the latest production versions of all available formats. If you want a different format of the same version of the document you are reading now, then you should try your current distro. If you want the latest production version, you should try http://pub.admc.com/howtos.

Sometimes, distributions other than http://pub.admc.com/howtos do not host all available formats. So, if you can't access the format that you want in your current distro, you have no choice but to use the newest production version at http://pub.admc.com/howtos.

Table 1. Available formats of this document


If you are reading this document now with a standalone PDF reader, the your distro links may not work.

License

This HOWTO document is copyrighted by Axis Data Management Corp. and may not be modified.

Purpose

I am writing this HOWTO because, in my opinion, JUnit is very simple and easy to learn, but there is no tutorial or HOWTO out there which is

  • concise
  • explains JUnit architecture accurately enough so that readers can figure out how to use JUnit in new situations
  • accurate

(Due to both design improvements as well as decisions not to support several features with JUnit versions 4.x, the second item above is now largely obsolete).

The tutorial that I used to learn JUnit spent about 80% of my time learning the program that was to be tested as an example, and the resultant tutorial therefore took five times longer to digest than it should have. There is no need to learn to understand somebody else's data structures just to learn JUnit. If you have an hour to learn to use a terrific product, then proceed.

Coverage

Most importantly this document covers only versions 4.x of JUnit. There are business and technical situations which require using JUnit 3.x, most importantly when you must support Java 1.3. For those situations, you should see our JUnit 3.x Howto . I have purposefully dropped coverage of all 3.x-specific features from the Howto you are reading now, in order to make it more accessible (and less scary) to the mainstream users who wish to use the current version of JUnit. A few aspects I cover may be sub-version-specific, and in that case, what I say applies to JUnit version 4.5.

Feature-wise, I cover all of the procedures and features necessary for meaningful unit testing. In addition, I cover how to execute tests from the command-line, from Ant, and from IDEs.

I only cover how to execute tests graphically from IDE's, since JUnit 4.x dropped direct support for graphical test runners. It is not difficult to use the 3.x graphical test-runners in a JUnit 4.x environment, but I'm not going to spend time trying to support environments which the JUnit dev team is aborting. I am not covering test suites for the same reason-- that they are not directly supported by JUnit 4.x. I would very much like to cover the very useful features Categories and Assumptions, however, these features are still experimental. Out of concern for your time and my time, I don't want to waste time explaining features which are likely to change drastically. (Been burned by that one-too-many times).

I'm not covering the new assertThat syntax, because I think it is less intuitive than the traditional JUnit assertion syntax (and consider the assertion that it is More readable to be arguable). The JUnit team promises to support the traditional syntax indefinitely. I am not covering Theories because the field of application is rather limited, and the design is invasive and heavy-handed. It's hard enough to get unit testing adopted by a development team without throwing in high-maintenance components.

Support

Use the designated topic at the support forum at http:/admc.com/jforum/ with questions, suggestions, etc., about this document or its subject. Axis Data Management Corp. provides professional development, support, and custom education for JUnit implementations, as well as for many other subjects in the realms of computer systems and software development.


$Revision: 2422 $