I am using these two Maven Dependencies to generate Extent Report with Cucumber (I am also using TestNG in the framework for parallel testing): 1. Extentreports-cucumber4-adapter- version 1.07 and 2.Extent Reports- version 4.09
I am using the TestRunner class to execute the scenarios in the Feature file.
I do not have any classes apart from the above two dependencies to generate the Extent report.
My question is- How do I generate the Logs in the Extent report? What changes do I need to do in the TestRunner class? I do not want to add code in each and every step definition file.
Done research on the stack overflow
This is my test runner class:
import org.junit.runner.RunWith;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.DataProvider;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
//import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.TestNGCucumberRunner;
import io.cucumber.testng.AbstractTestNGCucumberTests;
@RunWith(Cucumber.class)
@CucumberOptions(
features="src/test/resources/features/APIPortingGET.feature" ,
glue= {"stepDefinition"}, //step definition file
plugin = {"pretty", "html:test-output", "json:target/cucumber-json-report.json", "junit:junit_xml/cucumber.xml", "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:test-output/HtmlReport/SOAReport.html"},
monochrome = true,//displays the console output in a readable format
dryRun = false//to check mapping is proper between feature and step def file
//strict = true // will fail the test if there are undefined steps in the step def file or the mapping between the feature file and step def file is wrong
//tags= {"@debug"}
)
public class TestRunner extends AbstractTestNGCucumberTests {
private static TestNGCucumberRunner testNGCucumberRunner;
ExtentTest test;
ExtentReports extent;
@Override
@DataProvider(parallel=true)
public Object[][] scenarios() {
return super.scenarios();
}
}