Here are some tips for troubleshooting Arquillian, mostly for Maven / JUnit usage with the JBoss AS container.
Tests run, Arquillian doesn't start, NPE on @EJB / @Inject values
This usually means the tests are not integrated with Arquillian. Arquillian will not start if the test doesn't specify it. In turn, the container won't start.
- For JUnit tests, add
@RunWith(Arquillian.class)
- For TestNG tests, extend
org.jboss.arquillian.testng.Arquillian
- Make the Maven Project has dependencies / surefire configuration for either JUnit or TestNG, not both. Surefire will either not run the tests at all, or it won't start Arquillian.
- Only one test container integration dependency. e.g.
org.jboss.arquillian.junit:arquillian-junit-container
ororg.jboss.arquillian.testng:arquillian-testng-container
. Never both! - Similarly, ensure that only one of the test frameworks is a dependency.
- Only one test container integration dependency. e.g.
Null @EJB values
If @EJB fields are null:
- Make sure Arquillian is actually starting the container.
- EJB3.1 'interface-less' EJBs are not injected (by Arquillian v1.1.2 at least). Add local interfaces and it will work.
Comments