简体   繁体   English

TestNG @BeforeClass和测试类构造函数之间的区别

[英]Difference between TestNG @BeforeClass and test class constructor

What is the difference between TestNG's @BeforeClass and the test class' constructor? TestNG的@BeforeClass和测试类的构造函数之间有什么区别? How does it work internally? 它在内部如何运作?

  1. @BeforeClass methods are invoked after test class instantiation. 在测试类实例化之后调用@BeforeClass方法。
  2. Exceptions in constructor will just abort TestNG test execution and no report will be created. 构造函数中的异常将中止TestNG测试执行,不会创建任何报告。 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). 虽然@BeforeClass中的异常将显示在结果报告中,但将跳过类测试方法(可以使用-configfailurepolicy TestNG参数调整此行为)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM