What is the testng equivalent of junits @ClassRule

2019-07-16 05:51发布

问题:

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