• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to unit test MDBs and session beans ?

 
Adwait Bramhe
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the best practices for unit testing MDBs and session beans ?

How can they be tested without running an application server ?
 
Michael Remijan
Author
Ranch Hand
Posts: 131
7
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course. They are just POJO's so you unit test them like any other POJO. Use Mockito (or some other mocking framework) for the dependent classes and write your unit tests to verify that bean is working correctly.

The EJB 3 In Action Second Edition book has an entire chapter on testing. It covers unit tests and more advanced integration tests where the beans are run in an embedded container against real external resources.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!