wood burning stoves 2.0*
The moose likes Testing and the fly likes Testng is skipping @Before annotation from junit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Testng is skipping @Before annotation from junit" Watch "Testng is skipping @Before annotation from junit" New topic
Author

Testng is skipping @Before annotation from junit

appu sharma
Ranch Hand

Joined: Sep 20, 2009
Posts: 104

Hi,

I am trying to run run below code but testng is skipping @Before annotation, What is the reason behind it.

Here is the code.




It doesn't matter if you win by an inch or a mile; winning's winning.
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Greetings Sharma ,

Testng uses the @BeforeMethod instead of the JUNIT @Before annotation.


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
appu sharma
Ranch Hand

Joined: Sep 20, 2009
Posts: 104

Thanks for reply Asif,

I know @BeforeMethod and @BeforeClass is working fine but if why testNG skipped junit annotation?? any idea!!!


Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

It is dependant on the framework which you invoke to run the test cases. If you run with JUNIT , then the JUNIT annotations will be read and the TestNG annotations will be skipped. Same scenario is with TestNG. The TestNG does not understand the JUNIT annotations.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Testng is skipping @Before annotation from junit