I am new to Selenium,Cucumber Tool and am learning to build a BDD Framework using Selenium,cucumber,maven and TestNG.
I have basically Three Java files- Test-Runner(src/test/java) Step-Definition(src/test/java) TestBase(src/main/java)
I have before and after hooks defined inside TestBase Class My Test-Runner class has a Plugin defined for Extent-report and also it has @AfterClass annotation which is loading the extent-config.xml-
Now when am running the Feature files, it doesn't execute the @AfterClass annotations, hence skips generating extent Report. But if I run directly Test-runner file using TestNG, it skips executing Hooks defined in testBase Class-
Code of Test-Runner-
@CucumberOptions(
features={"src/test/resources/Features/login"},
glue={"stepDefinition","src/main/java/Utils/TestBase.java"},
monochrome=true,
plugin={"pretty","html:target/Reports","com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html"}
)
public class Login_Runner extends AbstractTestNGCucumberTests{
@AfterClass
public static void writeExtentReport() {
System.out.println("I am in After Class");
Reporter.loadXMLConfig(new File("src/test/resources/extent-config.xml"));
}
Can anyone help to solve this issue???
AfterClass
should be executed. – SubOptimal