Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between TestNG @BeforeClass and test class constructor

What is the difference between TestNG's @BeforeClass and the test class' constructor? How does it work internally?

like image 902
Sarath Avatar asked Sep 29 '22 13:09

Sarath


1 Answers

  1. @BeforeClass methods are invoked after test class instantiation.
  2. Exceptions in constructor will just abort TestNG test execution and no report will be created. Whereas exceptions in @BeforeClass will be displayed in resulting report and class test methods will be skipped (This behaviour can be tweaked using -configfailurepolicy TestNG parameter).
like image 62
mies Avatar answered Oct 07 '22 19:10

mies