Hello,
I'm working on an application built using J2EE and running under
Glassfish v2u2. I use NetBeans 6.5 for development. I'm trying to find
the best strategies for testing my application. I am used to using unit
tests, so I've been looking at JUnit. I also attended a session at the
last JavaOne which discussed DBUnit. I like DBUnit because my
application is heavily database dependent and I'd like to put the
database into a testing state so I can test various specific scenarios.
I currently have static (not running under Glassfish) and runtime
(running under Glassfish) tests built, but only a couple. I plan on
using a mix of various tests to comprehensively test my application.
My issue is that I need to test methods which interact with the database
and which use an entitiy manager within Glassfish. So static testing
with JUnit and/or DBUnit will not work since my methods being tested
expect to have a J2EE entity manager available. Runtime testing with
JUnit/DBUnit does not seem to work. If I extend either of these classes
and build a test to instantiate my extended class, the tests don't
run...as if the class never was instantiated. I would expect at least
an error around not finding appropriate J2EE container information. I
am starting to look into using mock testing. I'm also looking into
using EJB3Unit (
http://ejb3unit.sourceforge.net), which looks promising,
and TestNG, which I have seen some Glassfish blog posts which state
Glassfish itself is tested using TestNG. Part of the problem I'm having
is as I search the Internet for testing frameworks for J2EE
applications, most of what I see is old (e.g. J2EEUnit) and not in use
or at least not in development any longer. It's almost as if various
strategies have been tried, but nothing nothing really worked so work on
it stopped.
What is the best way to perform testing on J2EE applications and which
testing frameworks should I be looking at?
Thanks,
Darryl