Introduction to JUnit
Creating basic JUnit 4.0 test
This article marks the first in a series here at Remember Java which will look at technologies outside the core Java API. One such very relevant technology is
JUnit
for creating white box unit testing for your Java code. This and future articles will focus on JUnit 4.x, which requires Java JDK 5.0 or later. JUnit 4.x uses Java
annotations
, for marking various aspects of the test cases. JUnit is a Free and Open Source project, and junit.org is the official web site, where you can download the Jar you need for free.
|
|
Load resources
Find external resource files
When loading images, data files and other external resource files for an
application, some path often has to be specified. It is then most useful
to specify a relative path, and search for the file dynamically in runtime.
These small example shows how to build in a little redundancy when loading
files.
|
Save that screen
Simple screencapture and image output
Caputring the screen is easy in Java, using the
java.awt.Robot class. Saving is also a breeze,
with the javax.imageio package. Binding it all together, is the
java.awt.image.BufferedImage class.
|
|
|