How to test J2EE Applications
Most java developers use (ok, ok maby just know about
) Junit. JUnit provides an effective and easy way to unit test client-side Java applications. Here is an very short example, just to see how easy you can build client-side Junit tests:
{[.junit1 /enzymes/s_java.php]}
JunitEE
But Junit has some limitations, therefore, testing in each application server container becomes a tedious process. The JunitEE test framework addresses these limitations. This framework extends the standard JUnit so that tests can be executed in an application server container. JunitEE is configured in the J2EE Web module of a unit test application, and it uses a TestRunner to output HTML or XML test results. So according to Junitee.org there are following benefites :
- Your tests are packaged conveniently into a .war file which can easily be moved between servers; you can leave the .war file in the main .ear file and simply avoid enabling the test web application on the production server.
- Your test classes will be dynamically reloaded by the app server (assuming your server supports this).
- Your test cases look just like your production code, and can use the same beans (or whatever) you use as a facade for your EJBs.
How it works? Roughly it could be described like below, see resources for detailed examples:
- Develop JUnit test cases
- Create and configure a JUnitEE test modulePlace
junit.jarandjunitee.jarfiles in the project classpath by placing them in theWEB-INF/libdirectory- a jar file, like
MyUnitTest.jar, containing your Test classes. Copy this fileinto theWEB-INF/libdirectory too - Include in the Servlet description like shown below in the
web.xmldeployment descriptor
- Deploy and execute test cases on the Application Server.
{[.xml1 /enzymes/xml.php]}
Resources
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.



Comments
No comments yet.
Leave a comment