How to generate extent report in Ready API using Groovy script at Project level
Hi,
I was able to create Extent report at Test Suit level which I found in one of the existing post. But I need to know how it can be created at Project level as I have multiple test suites in my project? Any information will be helpful.
Below is the script I am using at suit level:
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import java.text.SimpleDateFormat
def date = new Date()
sdf = new SimpleDateFormat("dd_MM_yyyy_HHmmss")
def start_time = sdf.format(date)
log.info(start_time)
def path = "C://Reports//API_Testing_"+start_time+".html"
log.info(path)
def LogStatus = com.relevantcodes.extentreports.LogStatus;
def failedTestCase = 0;
def extent = new ExtentReports(path,false)
extent.addSystemInfo("Report Name", "TestReport").addSystemInfo("Report Type", "Automation Report");
runner.results.each {
testCaseResult -> def name = testCaseResult.testCase.name
log.info name
def extentTest = extent.startTest("$name", "$name")
if(testCaseResult.status.toString() == 'FAILED')
{
failedTestCase++
extentTest.log(LogStatus.FAIL, testCaseResult.testCase.name)
} else
{
extentTest.log(LogStatus.PASS, testCaseResult.testCase.name)
}
extent.endTest(extentTest);
}
extent.flush();
jaimin ,
There is no difference to create report in suite or project level.
all of running information in runner (actually it's runner.results). you just needs to fine-tune your scripts then can use it in project level.
Please be aware that project runner.results -> TestSuiteRunner -> TestCaseRunner. so you can collect all of running information from result sets.
Thanks,
/Aaron