Java Reference
In-Depth Information
You could jokingly say that writing software doesn't create bugs, testing does. But
if you ever intend to have an application used by anyone of consequence (a pay-
ing customer, for example), then the application must undergo some form of test-
ing. Most applications also go through many changes and improvements. Testing
becomes far more difficult the longer an application is in development, because
you're not just testing new features—you have an obligation to maintain the old
features, as well.
This area of continuing development is where automated unit testing comes
into its own. Writing tests at the same time as the application code not only con-
firms the proper working of the application in the short term but also provides an
automated means to confirm the application continues to work in the future.
JU nit (an open source project with excellent pedigree) has become a de facto
standard in unit testing, and it's almost ubiquitous for unit testing in Java. IDEA
has a very high degree of integration with JU nit. This integration provides the
most productive means to write, manage and run unit tests without leaving the
comfort of the IDE .
7.1 T esting applications with JUnit
Thorough, automated suites of unit tests are a cornerstone of the Extreme Pro-
gramming movement and should be part of any large-scale development project.
For the uninitiated, unit tests are used to programmatically verify the operation of
code components, often down to the individual methods. By developing extensive
unit tests for your code and running them often as part of the build and verifica-
tion process, you can help reduce bugs and avoid regressions. IDEA encourages
this practice through its integrated support for JU nit.
JU nit is a free unit-testing framework developed by superstars Kent Beck (of
Extreme Programming fame) and Erich Gamma (master of design patterns). The
package is built around a straightforward API that lets you create tests that verify
your code's correct operation. You can learn the details of the framework and the
JU nit API at http://www.junit.org. For the brave and impatient, we'll give a quick
overview to get you started.
7.1.1
Understanding the JUnit philosophy
The benefit of using the JU nit framework is that it lets you write automated unit
tests for your Java code so easily that you can't reasonably justify not doing so. The
API is simple, readable, and—most important—painless.
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search