1 Reply Latest reply on Jul 28, 2012 12:33 PM by Sueleyman Vurucu

    NullpointerException for @BeforeMethod in TestNG

    Sueleyman Vurucu Expert

      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:





      UserTransaction utx




      public void startUTX(){






      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