Where can I find good unit testing resources for E

2019-01-21 08:50发布

问题:

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

回答1:

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



回答2:

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.");
}


回答3:

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



回答4:

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



回答5:

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.