Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this questionWhich online resources, tutorials or books can you recommended to get started with unit testing J2EE / EJB3 applications?
So far I have found ejb3unit, Jakarta Cactus (retired 2011/08) and the Maven Cargo plugin. It would be helpful if there are complete working examples, ready to run.
Target containers are the open source products GlassFish, JBoss and Apache OpenEJB.
EJB Unit Testing with Eclipse and OpenEJB
Article on Testing EJB
Glassfish EJB 3.0 Unit testing
JUnitEE Tutorial
Effective Unit Testing EJB 3.0 with OpenEJB
JUnitEE IBM Tutorial
The next version NetBeans 6.8 includes a nice new feature: it generates Unit-Tests for EJB 3.1 with Embeddable Container code.
@Test
public void testHello() throws Exception {
System.out.println("hello");
HelloService instance = (HelloService)javax.ejb.embeddable.EJBContainer.createEJBContainer().getContext().lookup("java:global/classes/HelloService");
String expResult = "";
String result = instance.hello();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
EJB out-of-container testing by Erwann "Airone" Wernli
JSFUnit is "a test framework for JSF applications. It is designed to allow complete integration testing and unit testing of JSF applications using a simplified API. JSFUnit tests run inside the container, which provides the developer full access to managed beans, the FacesContext, EL Expressions, and the internal JSF component tree. At the same time, you also have access to parsed HTML output of each client request."
There is nice book on TDD written by Lasse Koskela
It has a free to download web extra based on EJB testing.Grab it and roll up your sleeves.
精彩评论