Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testng is skipping @Before annotation from junit

 
appu sharma
Ranch Hand
Posts: 104
Java Netbeans IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings Sharma ,

Testng uses the @BeforeMethod instead of the JUNIT @Before annotation.
 
appu sharma
Ranch Hand
Posts: 104
Java Netbeans IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic