Quick Note: OpenEJB embedded Arquillian adapter and code coverage


To get code coverage with Arquillian we often use jacoco because:

  • there is an arquillian extension 🙂
  • cobertura, emma…doesn’t work

This is generally true but if you try to use jacoco with OpenEJB embedded Arquillian adapter (this note applies to OpenWebBeans adapter too) it will fail. Why? Simply because this adapter is not a standard one for Arquillian since it is embedded, the JVM is shared between the client and the server…You can remove the jacoco extension and use the jacoco maven plugin/javaagent…but there is easier.

Yes that’s embedded so you can use what you want: cobertura (or Emma) works!

Note on using cobertura in an EJB container: cobertura instruments classes adding an interface. It means if you have a @Local EJB it will magically implement two interfaces (your business one and the Cobertura one). From a spec point of view the deployment will fail. The workaround is to specify as @Local parameter the business interface the bean implements: @Local(MyBusiness.class). In the same idea, @LocalBean becomes mandatory with cobertura (it is not otherwise).

Advertisements

2 thoughts on “Quick Note: OpenEJB embedded Arquillian adapter and code coverage

  1. creativemanju

    Hi , I am facing Cobetura deplyment issue, Can you please provide me with example ? Say I have TestDao.java which is a local interface and TestDaoImpl.java which is stateless bean implements TestDao, please let me know what change i need to make in this case

    Reply
    1. rmannibucau Post author

      IIRC cobertura is adding an interface (having the error would help + you can send it over opeenjb/tomee lists, it would be useful for others too). If so just declare the interface you want as business interface (@Local(MtApi.class) in TestDaoImpl)

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s