Java Reference
In-Depth Information
Figure 14.4
XML result in the browser from Cactus tests
the
<junitreport>
Ant task), and drop it in your web app (in the root directory, for
example). Then, open a browser and type
mytestcase&xsl=cactus-report.xsl.
The .xsl stylesheet will generate the
HTML
report you're familiar with, so you can view
it from within your browser.
14.10 Summary
When it comes to unit testing container applications, pure
JU
nit unit tests come up
short. A mock objects approach (see chapter 7) works fine and should be used. But it
misses a certain number of tests—specifically integration tests, which verify that com-
ponents can talk to each other, that the components work when run inside the con-
tainer, and that the components interact properly with the container. In order to
perform these tests, an in-container testing strategy is required.
In the realm of Java
EE
components, the de facto standard framework for in-
container unit testing is Jakarta Cactus. In this chapter, we ran through some sim-
ple tests using Cactus, in order to get a feel for how it's done. We also discussed
how Cactus works, so we're now ready to in-container test our Java
EE
applications.
Testing the components from the Java
EE
spec is nice, but it isn't the whole picture.
Most of our applications are heavily framework based. In the next chapters, we
explore one of the most widely used
MVC
frameworks,
JSF
. We also introduce the
JSFU
nit project, which will let you test your
JSF
application inside the container.