@Before method will run before every scenario. Do we have an annotation where it run before any of the scenarion and an annotation after all the scenarios have been executed ?
You can use gerkin with qaf where you can use different TestNG listeners and annotations. In addition to that if you are using webdriver you can get additional driver and element listeners support. For example
package my.test.pkg
public class MyClass{
@BeforeSuite
public void beforeSuite() {
//get executed before suite
}
@BeforeTest
public void beforeTest() {
//get executed before each xml test
}
@BeforeMethod
public void beforeMethod() {
//get executed before each test case/scenario
}
@BeforeGroups(["p1","p2"])
public void beforeMethod() {
//get executed before group
}
//same for after methods @afterXXXXX
}
You need to add class in config file:
<test name="Gherkin-QAF-Test">
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
<class name="my.test.pkg.Myclass" />
</classes>
</test>
This example is not using listeners. You also can use different listeners.