Junit has a decorator called @ClassRule that is applied around the test class. I am trying to find the same thing in testng without any success this far. What would be the best way to do a @ClassRule in testng?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
As far as I know, there's no direct testng equivalent, but it's generally easy to do the same thing using the @AfterXXX/@BeforeXXX
annotations. In your case, you could use @BeforeClass
and @AfterClass
annotations on 2 different methods to emulate the same thing
You can find more information on the supported annotations on the testng website