Reputation: 1203
Is it possible to call testing a bean or bean method (or a unit) after deploying it on an embedded container as "Unit Testing". IMO, I feel it is possible because,
I agree that there is quite a lot that can be debated on this topic and I also do agree that what I mentioned above may not be right. So I would like to hear from you all if what I am thinking is right or if I am missing some point. As far I see, there is no single and solid definition for Unit testing. If there are any, kindly provide me some pointers and it will be of great help to me.
Thanks a lot for your support. - Ganesa...
Upvotes: 3
Views: 418
Reputation: 4941
I think the answer entirely depends on what are you doing in your tests.
According to the definition of unit testing, (it) is a method by which individual units of source code are tested to determine if they are fit for use. A unit is the smallest testable part of an application. If you need an embedded container to test that smallest unit of code, then yes, it is unit testing.
An example for me would be using a Hypersonic DB for DAO testing. It is not possible to test JPA queries without an in-memory DB (as far as I know) and they are the smallest part of the code of a DAO method.
However, if you are using an embedded container to test an EJB method and they way it collaborates with other injected EJBs or POJOs (e.g. via CDI) then I would consider this integration testing. You are now not testing the smallest bit of code but also something else (other collaborating EJBs or POJOs) and you would need to mock the collaborators to truly test the smallest chunk of code of the EJB.
Upvotes: 2