How do you unit test Java EE code?

If by Unit Testing you mean… unit testing (testing a unit in isolation), then you actually don’t need any particular framework since EJB3.0 are nothing more than annotated POJOs and thus can be relatively easily tested without any special fixture.
Now, if you mean something else – like Integration Testing or Functional Testing – then, yes, tools can help and simplify things (but you should really start to use the right terminology 🙂 I’ll assume that this is what you have in mind.
First, JUnitEE seems dead and obsolete and I’m not even sure it has anything for EJB3.x. Second, I’m not impressed by the Java EE 5 support of Cactus and having to deploy Cactus tests is painful (I think that Cactus was nice for J2EE 1.4 but is a bit outdated now). So this leaves us with Ejb3Unit which is in my opinion the best option, especially if you want to run out of container tests i.e. without really deploying the application (much faster).
If you want to run in container tests, then you could indeed use an embedded container and my current preference goes to GlassFish v3, even for Java EE 5 (I may be wrong but I’m pretty disappointed by the starting time of the latest JBoss releases so it isn’t getting much of my attention). See the post GlassFish Embedded Reloaded, an appserver in your pocket for sample code (that you could use from your tests) or Using maven plugin for v3 embedded glassfish (if you are using maven).
Another option would be to package and deploy your application with Cargo and then run some tests against the deployed application (with Selenium or a BDD tool for example). This could be useful if you want to run end-to-end tests with a container that doesn’t provide any embedded API.
So, to answer your last question, I would indeed use available tools, maybe a combination of them, for tests that are not unit tests and wouldn’t mock/inject stuff myself, except if they don’t cover some needs that I can’t think of right now.

http://stackoverflow.com/questions/1947846/how-do-you-unit-test-java-ee-code

What are unit testing and integration testing, and what other types of testing should I know about?

  • unit testing in the sense of “testing the smallest isolatable unit of an application”; this is typically a method or a class, depending on scale
  • integration testing
  • feature testing – this may cut across units, and is the focus of TDD
  • black-box testing: testing only the public interface with no knowledge of how the thing works
  • glass-box testing: testing all parts of a thing with full knowledge of how it works
  • regression testing: test-cases constructed to reproduce bugs, to ensure that they do not reappear later
  • pointless testing: testing the same basic case more than one way, or testing things so trivial that they really do not need to be tested (like auto-generated getters and setters)

http://stackoverflow.com/questions/437897/what-are-unit-testing-and-integration-testing-and-what-other-types-of-testing-s

What is Unit test, Integration Test, Smoke test, Regression Test?

  • Unit test: Specify and test one point of the contract of single method of a class. This should have a very narrow and well defined scope. Complex dependencies and interactions to the outside world are stubbed or mocked.
  • Integration test: Test the correct inter-operation of multiple subsystems. There is whole spectrum there, from testing integration between two classes, to testing integration with the production environment.
  • Smoke test: A simple integration test where we just check that when the system under test is invoked it returns normally and does not blow up. It is an analogy with electronics, where the first test occurs when powering up a circuit: if it smokes, it’s bad.
  • Regression test: A test that was written when a bug was fixed. It ensure that this specific bug will not occur again. The full name is “non-regression test”.

To this, I will add:

  • Acceptance test: Test that a feature or use case is correctly implemented. It is similar to an integration test, but with a focus on the use case to provide rather than on the components involved.

http://stackoverflow.com/questions/4055736/what-is-a-smoke-test