mercredi 25 février 2015

How do I organize structure of my testSuite using beforeClass, afterClass, afterSuite in testNG?

I m confused about using annotations @beforeClass,afterClass, beforeSuite,afterSuite in testNG.


I understand test structure below:



package mytestNG.learning.it ;

public class sample_not_working {
@Test
//take action - click on links, input data etc
public void main() {
}
@BeforeMethod
//do stuff like setup browser etc
public void beforeMethod() {
}

@AfterMethod
//close browser
public void afterMethod() {
}
}


But what do you do in beforeclass,afterClass and test? What file is it? Is it a class that runs other classes?


Next, afterSuite, beforeSuite and @test :



public class sample_not_working {
@Test

public void main() {
//WHAT KINDA CODE YOU PUT HERE?
}
@BeforeSuite
//WHAT KINDA CODE YOU PUT HERE?
public void beforeMethod() {
}
@AfterSuite
public void afterMethod() {
//WHAT KINDA CODE YOU PUT HERE?
}
}


My question is about semantics, the meaning, not actual code. I read the testNG docs - did not help.


Aucun commentaire:

Enregistrer un commentaire