I migrated my tests from JUnit to TestNG. In JUnit I have no problem when I use injected field with @Before. But when I use @BeforeMethod in TestNG I get a Nullpointerexception.
It seems so that the method called on wrong time. If I catch the NullpointerException then it works fine. Example shown below:
....
@Inject
UserTransaction utx
...
@BeforeMethod
public void startUTX(){
if(utx!=null){
utx.begin();
}
}
So at test initialisation the NullPointer occurs. Afterwards the testcase works fine.
My env:
Jboss 7.1.1
Arquillian 1.0.2.Final
TestNG 6.5
I found a similar problem here.
I see a thread in StackOverflow which is realted to ARQ-351. So I think this is a bug in ARQ 1.0.x and will be fixed in 1.1.0.CR1 right ?