views:

695

answers:

5

Which 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 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.

+2  A: 

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.");
}
mjustin
+1 For using the embedded API (and GlassFish!). See http://blogs.sun.com/alexismp/entry/testing_ejb_3_1_s
Pascal Thivent
+2  A: 

EJB out-of-container testing by Erwann "Airone" Wernli

Adrian
A: 

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."

mjustin
A: 

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.