Forum Discussion
- HimanshuTayalCommunity Hero
ashsharma22 : You can use below link for the extent report integration with ReadyAPI
https://community.smartbear.com/t5/SoapUI-Pro/How-to-use-extent-report-in-Ready-API-tool/td-p/155680
- sonya_mSmartBear Alumni (Retired)
- ashsharma22Occasional Contributor
Thanks Himanshu for the help!
I did few more modification in the script and made it dynamic.
Step1: Only below imports needed
Step2: Add TestReport property at project level: ${projectDir}/TestReport; This location all extents reports will be stored
Step3: keep this code at suite level
Run it;
import java.io.File;
import java.util.Date;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
import com.aventstack.extentreports.reporter.configuration.Protocol;
import com.aventstack.extentreports.reporter.configuration.Theme;log.info "start"
ExtentReports extent;
ExtentTest extentTest;
def testReport = context.expand( '${#Project#TestReport}' )
assert !testReport.equals(''), 'TestReport location not found'
log.info "testReport: "+testReportif (extent == null) {
//ExtentReport file name
Date d=new Date();
String fileName=d.toString().replace(":", "_").replace(" ", "_")+".html";
//String folderName="C:\\reports\\";File folderPath=new File(testReport);
if(!folderPath.exists()) {
log.info "Directory created"
folderPath.mkdir();
} else
log.info "Directory already exists"String htmlFilePath=testReport+'/'+fileName;
log.info 'HTML File Path' + htmlFilePath
ExtentHtmlReporter htmlReporter=new ExtentHtmlReporter(htmlFilePath);
extent=new ExtentReports();
extent.attachReporter(htmlReporter);
htmlReporter.config().setCSS("css-string");
htmlReporter.config().setDocumentTitle("Automation Execution Report");
htmlReporter.config().setReportName("Test Automation Report");
htmlReporter.config().setEncoding("utf-8");
htmlReporter.config().setJS("js-string");
htmlReporter.config().setProtocol(Protocol.HTTPS);
htmlReporter.config().setReportName("build name");
htmlReporter.config().setTheme(Theme.STANDARD);
htmlReporter.config().setTimeStampFormat("MMM dd, yyyy HH:mm:ss");
}
for ( testCaseResult in runner.results ) {
// Getting all test cases’ names from the suite.
testCaseName = testCaseResult.getTestCase().name
extentTest = extent.createTest(testCaseName);// Checking whether the case has PASSED.
if ( testCaseResult.getStatus().toString() == 'PASS' ) {
// Logging passed cases and test steps’ resulting messages.
extentTest.log(Status.PASS, testCaseName);
log.info "$testCaseName has passed"
for ( testStepResult in testCaseResult.getResults() ) {
testStepResult.messages.each() {
msg -> log.info msg
extentTest.log(Status.INFO, msg);
}
}
}
// Checking whether the case has failed.
if ( testCaseResult.getStatus().toString() == 'FAIL' ) {
// Logging failed cases and test steps’ resulting messages.
log.info "$testCaseName has failed"
extentTest.log(Status.FAIL, testCaseName);
for (testStepResult in testCaseResult.getResults() ) {
testStepResult.messages.each() {
msg -> log.info msg
extentTest.log(Status.INFO, msg);
}
}
}
}
extent.flush();
Related Content
- 3 years ago
- 3 years ago
Recent Discussions
- 2 days ago