2

I am developing a Java Enterprise application and I would like to unit test it.

Does anyone know which tool I should use to do so, and does anyone know any examples or tutorials?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Viola
  • 113
  • 4
  • 13
  • Java Enterprise application can intend for to many types of technologies: JSF, Servlets, JSP, JPA, EJB 3, EJB 2.1, Wicket, Struts, etc. The way for made unit tests will depend of the technologies that you will use inj your app. Please provide more information. – Ernesto Campohermoso Nov 21 '11 at 22:14
  • I am using JavaEE 6 , glassfish 3.1. – Viola Nov 21 '11 at 22:19
  • possible duplicate of [How do you unit test Java EE code?](http://stackoverflow.com/questions/1947846/how-do-you-unit-test-java-ee-code) – Martin Schröder Jan 15 '14 at 14:34

4 Answers4

2

I will assume that by 'Enterprise Application' you mean mainly the EJB part of it.

So, if you want to test EJB 3.1 (as you're working on Java EE 6) you can use the environment of your choice - just like for any other non-Java EE development - i.e. JUnit - and use the EJB embedded container feature. It should do the work for unit testing.

For integration testing I hope you'll find this link to be of any help: In TDD, why OpenEJB and why Arquillian?

Community
  • 1
  • 1
Piotr Nowicki
  • 17,914
  • 8
  • 63
  • 82
0

If you are looking for integration tests then have a look at Arquillian.

For ordinary unit tests, you should testing behaviour of isolated objects, Mockito, PowerMockito and JUnit are your friends

peter_pilgrim
  • 1,160
  • 11
  • 18
0

For an annotation-based EJB that uses dependency injection (which all newly-developed EJBs on Java EE 6 should be) you don't really need anything except a testing framework (usually JUnit, but TestNG is supposed to be better) and a mocking framework (Mockito and EasyMock are popular choices). The rest is pretty straightforward, as described in this article.

Of course, there's a lot more to Java EE than EJBs, and for other parts of the stack (most notably web UIs), unit testing may require more elaborate techniques.

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
0

If You use Eclipse IDE I recommend You JUnit.

I think this site is a good point for beginners.