djangofan
djangofan

Reputation: 29689

What are standard names for JUnit and TestNG "before" and "after" annotated methods?

What are standard names for JUnit and TestNG "before" and "after" annotated methods? Is this kind of thing standardized in the industry at all?

I am trying to guess at what names I should generally use and I came up with this. Can anyone improve on this? Would you say these are just fine?

 *   BeforeTest - setUpTest 
 *   AfterTest - cleanUpTest
 *   BeforeMethod - setUpMethod
 *   AfterMethod - cleanUpMethod
 *   BeforeClass - static setUpClass
 *   AfterClass - static tearDownClass
 *   BeforeSuite - static setUpSuite
 *   AfterSuite - static tearDownSuite

Upvotes: 0

Views: 139

Answers (1)

JB Nizet
JB Nizet

Reputation: 692171

You could also name methods after what they do, and not after when they run: populateTestDatabase(), prepareMocks(), whatever. The annotation already tells when the method runs.

Upvotes: 1

Related Questions