Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB wit TDD  RSS feed

 
Beppe Catanese
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can EJB be developed with a Test Driven Development approach?

Is that possible with Junit or should it require other tools/frameworks?

I am also interested in understanding which mocks should I consider and which part of the IJB code must instead be tested?


Thanks in advance :-)

Beppe
 
Michael Remijan
Author
Ranch Hand
Posts: 131
7
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJBs are just annotated pojos so yes they are very easy to test. remember to write your unit tests to test ONLY that EJB and mock out any other resources/dependencies the bean needs. As for TDD, everyone has an opinion and from my experience I would not take this approach. Code your bean, get it working, then use a unit test as a code-quality and -review tool to make your bean better. Once you start coding a unit tests, how to make your bean better will usually be very apparent. Got 20 dependencies in your bean you need to mock...probably you bean is doing too much work and taking too much responsibility. Got to write 10 tests to cover all branches of a method...method is probably too complicated. etc.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!