SlideShare uma empresa Scribd logo
1 de 7
Baixar para ler offline
Guide to Generate Extent Report in Kotlin
Guide to Generate Extent Report in Kotlin
© RapidValue Solutions 2
Extent Report Generation with Kotlin
 Pre-requisites
Following are the pre-requisites to generate Extent reports with Kotlin:
 Install Java SDK 8 and above.
 Install Eclipse or IntelliJ IDEA IDEs.
 Install the Kotlin plugin in IDEs. Here, we are using Eclipse as IDE and Kotlin plugin for Eclipse
downloaded from https://marketplace.eclipse.org/content/kotlin-plugin-eclipse.
 The latest version of following maven dependencies:
o testng
o selenium-java
o selenium-server
o kotlin-test
o kotlin-stdlib-jdk8
o extentreports
 Step-by-step Procedure
Step 1: Create a maven project and add the above dependencies in pom.xml of the project.
Step 2: Create a Kotlin class to keep the logic to generate the Extent Report. Let say the class name
is AutomationReport. Here, we are using ITestListener interface of TestNG to control the executions and
results. Below is the code snippet of the AutomationReport class to implement the ITestListener and
declare the objects for ExtentSparkReporter, ExtentReports, and ExtentTest,
class AutomationReport : ITestListener {
public lateinit var sparkReporter: ExtentSparkReporter
public lateinit var extentReport: ExtentReports
public lateinit var extentTest: ExtentTest
…}
Step 3: Create an override method onStart() with logic to generate an HTML template for the test report,
override fun onStart(testContext: ITestContext) {
try {
sparkReporter = ExtentSparkReporter(System.getProperty(“user.dir”) + “/AutomationReport/”)
sparkReporter.config().setDocumentTitle(“Kotlin Automation”)
sparkReporter.config().setReportName(“Automation Execution Report”)
sparkReporter.config().setTheme(com.aventstack.extentreports.reporter.configuration.Theme.DARK)
extentReport = ExtentReports()
extentReport.attachReporter(sparkReporter)
extentReport.setSystemInfo(“Application Name”, “Kotlin Report Demo”)
Guide to Generate Extent Report in Kotlin
© RapidValue Solutions 3
extentReport.setSystemInfo(“Platform”, System.getProperty(“os.name”))
extentReport.setSystemInfo(“Environment”, “QA”)
} catch (e: Exception) {
e.printStackTrace()
}
}
Step 4: Create an override method onTestStart() with logic to collect current test case name and add it to
the report,
override fun onTestStart(result: ITestResult) {
var testName: String = result.getMethod().getMethodName()
extentTest = extentReport.createTest(testName)
}
Step 5: Create an override method onTestSuccess() with logic to add pass status to the report,
override fun onTestSuccess(result: ITestResult) {
var testName: String = result.getMethod().getMethodName()
try {
extentTest.log(
Status.PASS,
MarkupHelper.createLabel(testName + ” Test Case PASSED”, ExtentColor.GREEN)
)
} catch (e: Exception) {
e.printStackTrace()
}
}
Step 6: Create an override method onTestSkipped() with logic to add skip status to the report,
override fun onTestSkipped(result: ITestResult) {
var testName: String = result.getMethod().getMethodName()
try {
extentTest.log(
Status.SKIP,
MarkupHelper.createLabel(testName + ” Test Case SKIPPED”, ExtentColor.ORANGE)
)
} catch (e: Exception) {
e.printStackTrace()
}
}
Step 7: Create an override method onTestFailure() with logic to add fail status to the report,
override fun onTestFailure(result: ITestResult) {
var driver: WebDriver
var currentClass = result.getInstance()
var testName: String = result.getMethod().getMethodName()
Guide to Generate Extent Report in Kotlin
© RapidValue Solutions 4
try {
driver = (currentClass as AutomationBase).getDriverInstance()
var screenshotPath = Utilities().screenshotCapture(driver, result.getName())
extentTest.log(
Status.FAIL,
MarkupHelper.createLabel(testName + ” Test Case FAILED”, ExtentColor.RED)
)
extentTest.log(
Status.FAIL,
MarkupHelper.createLabel(“Reason for Failure: ” + result.getThrowable().toString(),
ExtentColor.RED)
)
extentTest.addScreenCaptureFromPath(screenshotPath)
} catch (e: Exception) {
e.printStackTrace()
}
}
Step 8: Create an override method onFinish() with logic to store HTML report to the specified path and
flush extent report instance,
override fun onFinish(testContext: ITestContext) {
try {
extentReport.flush()
val dateFormat = SimpleDateFormat(“dd-MMM-yyyy_HH-mm-ss”)
val date = Date()
val filePathdate: String = dateFormat.format(date).toString()
var actualReportPath: String = System.getProperty(“user.dir”) + “/AutomationReport/” +
“index.html”
File(actualReportPath).renameTo(
File(
System.getProperty(“user.dir”) + “/AutomationReport/”
+ “Automation_Report_” + filePathdate + “.html”
)
)
} catch (e: Exception) {
e.printStackTrace()
}
}
Step 9: Create another class called Utilities to keep common utility functions required for automation. Here,
we just added one utility to capture the screenshot. In onTestFailure() method, we already used a method
called screenshotCapture(). Below is the code snippet to capture the screenshot,
fun screenshotCapture(driver: WebDriver, fileName: String): String {
var destination: String = “”
try {
var scrFile = (driver as TakesScreenshot).getScreenshotAs(OutputType.FILE)
var dateFormat = SimpleDateFormat(“yyyyMMddHHmmss”)
var cal = Calendar.getInstance()
var path = File(“Failure_Screenshots”).getAbsolutePath()
Guide to Generate Extent Report in Kotlin
© RapidValue Solutions 5
destination = path + “/” + fileName + dateFormat.format(cal.getTime()) + “.png”
scrFile.copyTo(File(destination))
} catch (e: Exception) {
e.printStackTrace()
}
return destination
}
Step 10: Prior to starting the automation execution, you have to map the AutomationReport class to your
test runner class (the class which starting your driver instance within TestNG annotation). You can
represent AutomationReport class in test runner class as below,
@Listeners(AutomationReport::class)
Step 11: Now, you can run your test cases using testng.xml and once execution complete the HTML report
will generate inside the AutomationReport folder in the project structure. Following are some excerpts of
the Extent Report:
We hope you got an idea of the Extent Report implementation using Kotlin language. Try to use the above
step-by-step procedure in your automation world and explore it.
Guide to Generate Extent Report in Kotlin
© RapidValue Solutions 6
Conclusion
Kotlin is a general-purpose, open-source, statically typed programming language that combines object-
oriented and functional programming features. So, it is a strong and powerful language that helps the
automation engineers to write their automation scripts and also develop the Extent Report. This article helps
the automation engineers to up skill and develop the extent reports using a different language like Kotlin.
By, Sanoj S, Test Architect, RapidValue
Guide to Generate Extent Report in Kotlin
© RapidValue Solutions 7
About RapidValue
RapidValue is a global leader in digital product engineering solutions including mobility, omni-channel, IoT, AI, RPA
and cloud to enterprises worldwide. RapidValue offers its digital services to the world’s top brands, Fortune 1000
companies and innovative emerging start-ups. With offices in the United States, the United Kingdom, Germany and
India and operations spread across the Middle-East, Europe and Canada, RapidValue delivers enterprise services
and solutions across various industry verticals.
Disclaimer:
This document contains information that is confidential and proprietary to RapidValue Solutions Inc. No part of it may
be used, circulated, quoted, or reproduced for distribution outside RapidValue. If you are not the intended recipient of
this report, you are hereby notified that the use, circulation, quoting, or reproducing of this report is strictly prohibited
and may be unlawful.
www.rapidvaluesolutions.com/blogwww.rapidvaluesolutions.com
+1 877.643.1850 contactus@rapidvaluesolutions.com

Mais conteúdo relacionado

Mais procurados (6)

Towed Systems for 2015RERmetricv3
Towed Systems for 2015RERmetricv3Towed Systems for 2015RERmetricv3
Towed Systems for 2015RERmetricv3
 
Les menaces applicatives
Les menaces applicativesLes menaces applicatives
Les menaces applicatives
 
Tuning the g1gc
Tuning the g1gcTuning the g1gc
Tuning the g1gc
 
Dependency Breaking Techniques
Dependency Breaking TechniquesDependency Breaking Techniques
Dependency Breaking Techniques
 
Apache Axis2におけるXML署名検証不備
Apache Axis2におけるXML署名検証不備Apache Axis2におけるXML署名検証不備
Apache Axis2におけるXML署名検証不備
 
essential instructions
 essential instructions essential instructions
essential instructions
 

Semelhante a Guide to Generate Extent Report in Kotlin

Semelhante a Guide to Generate Extent Report in Kotlin (20)

Appium Automation with Kotlin
Appium Automation with KotlinAppium Automation with Kotlin
Appium Automation with Kotlin
 
Migration to Extent Report 4
Migration to Extent Report 4Migration to Extent Report 4
Migration to Extent Report 4
 
Cómo tener analíticas en tu app y no volverte loco
Cómo tener analíticas en tu app y no volverte locoCómo tener analíticas en tu app y no volverte loco
Cómo tener analíticas en tu app y no volverte loco
 
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at RuntimeOSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
OSMC 2021 | inspectIT Ocelot: Dynamic OpenTelemetry Instrumentation at Runtime
 
Open Source ERP Technologies for Java Developers
Open Source ERP Technologies for Java DevelopersOpen Source ERP Technologies for Java Developers
Open Source ERP Technologies for Java Developers
 
Hot sos em12c_metric_extensions
Hot sos em12c_metric_extensionsHot sos em12c_metric_extensions
Hot sos em12c_metric_extensions
 
MAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR applicationMAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR application
 
Data Seeding via Parameterized API Requests
Data Seeding via Parameterized API RequestsData Seeding via Parameterized API Requests
Data Seeding via Parameterized API Requests
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Video Recording of Selenium Automation Flows
Video Recording of Selenium Automation FlowsVideo Recording of Selenium Automation Flows
Video Recording of Selenium Automation Flows
 
About Qtp 92
About Qtp 92About Qtp 92
About Qtp 92
 
About QTP 9.2
About QTP 9.2About QTP 9.2
About QTP 9.2
 
About Qtp_1 92
About Qtp_1 92About Qtp_1 92
About Qtp_1 92
 
The Ring programming language version 1.8 book - Part 77 of 202
The Ring programming language version 1.8 book - Part 77 of 202The Ring programming language version 1.8 book - Part 77 of 202
The Ring programming language version 1.8 book - Part 77 of 202
 
ITGM8. Всеволод Брекелов (Grid Dinamics) Component tests. let's do that!
ITGM8. Всеволод Брекелов (Grid Dinamics) Component tests. let's do that!ITGM8. Всеволод Брекелов (Grid Dinamics) Component tests. let's do that!
ITGM8. Всеволод Брекелов (Grid Dinamics) Component tests. let's do that!
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
The Ring programming language version 1.7 book - Part 75 of 196
The Ring programming language version 1.7 book - Part 75 of 196The Ring programming language version 1.7 book - Part 75 of 196
The Ring programming language version 1.7 book - Part 75 of 196
 
Android Test Automation Workshop
Android Test Automation WorkshopAndroid Test Automation Workshop
Android Test Automation Workshop
 
Hybrid framework
Hybrid frameworkHybrid framework
Hybrid framework
 
Asp.net tips
Asp.net tipsAsp.net tips
Asp.net tips
 

Mais de RapidValue

The Definitive Guide to Implementing Shift Left Testing in QA
The Definitive Guide to Implementing Shift Left Testing in QAThe Definitive Guide to Implementing Shift Left Testing in QA
The Definitive Guide to Implementing Shift Left Testing in QA
RapidValue
 

Mais de RapidValue (20)

How to Build a Micro-Application using Single-Spa
How to Build a Micro-Application using Single-SpaHow to Build a Micro-Application using Single-Spa
How to Build a Micro-Application using Single-Spa
 
Play with Jenkins Pipeline
Play with Jenkins PipelinePlay with Jenkins Pipeline
Play with Jenkins Pipeline
 
Accessibility Testing using Axe
Accessibility Testing using AxeAccessibility Testing using Axe
Accessibility Testing using Axe
 
Automation in Digital Cloud Labs
Automation in Digital Cloud LabsAutomation in Digital Cloud Labs
Automation in Digital Cloud Labs
 
Microservices Architecture - Top Trends & Key Business Benefits
Microservices Architecture -  Top Trends & Key Business BenefitsMicroservices Architecture -  Top Trends & Key Business Benefits
Microservices Architecture - Top Trends & Key Business Benefits
 
Uploading Data Using Oracle Web ADI
Uploading Data Using Oracle Web ADIUploading Data Using Oracle Web ADI
Uploading Data Using Oracle Web ADI
 
Build UI of the Future with React 360
Build UI of the Future with React 360Build UI of the Future with React 360
Build UI of the Future with React 360
 
Python Google Cloud Function with CORS
Python Google Cloud Function with CORSPython Google Cloud Function with CORS
Python Google Cloud Function with CORS
 
Real-time Automation Result in Slack Channel
Real-time Automation Result in Slack ChannelReal-time Automation Result in Slack Channel
Real-time Automation Result in Slack Channel
 
Automation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDDAutomation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDD
 
How to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular FrameworkHow to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular Framework
 
JMeter JMX Script Creation via BlazeMeter
JMeter JMX Script Creation via BlazeMeterJMeter JMX Script Creation via BlazeMeter
JMeter JMX Script Creation via BlazeMeter
 
The Definitive Guide to Implementing Shift Left Testing in QA
The Definitive Guide to Implementing Shift Left Testing in QAThe Definitive Guide to Implementing Shift Left Testing in QA
The Definitive Guide to Implementing Shift Left Testing in QA
 
Test Case Creation in Katalon Studio
Test Case Creation in Katalon StudioTest Case Creation in Katalon Studio
Test Case Creation in Katalon Studio
 
How to Perform Memory Leak Test Using Valgrind
How to Perform Memory Leak Test Using ValgrindHow to Perform Memory Leak Test Using Valgrind
How to Perform Memory Leak Test Using Valgrind
 
DevOps Continuous Integration & Delivery - A Whitepaper by RapidValue
DevOps Continuous Integration & Delivery - A Whitepaper by RapidValueDevOps Continuous Integration & Delivery - A Whitepaper by RapidValue
DevOps Continuous Integration & Delivery - A Whitepaper by RapidValue
 
A Technology Backgrounder to Serverless Architecture - A Whitepaper by RapidV...
A Technology Backgrounder to Serverless Architecture - A Whitepaper by RapidV...A Technology Backgrounder to Serverless Architecture - A Whitepaper by RapidV...
A Technology Backgrounder to Serverless Architecture - A Whitepaper by RapidV...
 
MS Azure: Soaring High in the Cloud - An Infographic by RapidValue
MS Azure: Soaring High in the Cloud - An Infographic by RapidValueMS Azure: Soaring High in the Cloud - An Infographic by RapidValue
MS Azure: Soaring High in the Cloud - An Infographic by RapidValue
 
An Essential Guide to Effective Test Automation Leveraging Open Source
An Essential Guide to Effective Test Automation Leveraging Open SourceAn Essential Guide to Effective Test Automation Leveraging Open Source
An Essential Guide to Effective Test Automation Leveraging Open Source
 
Cloud computing - The Trailblazer of Digital Transformation
Cloud computing - The Trailblazer of Digital TransformationCloud computing - The Trailblazer of Digital Transformation
Cloud computing - The Trailblazer of Digital Transformation
 

Último

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

Guide to Generate Extent Report in Kotlin

  • 1. Guide to Generate Extent Report in Kotlin
  • 2. Guide to Generate Extent Report in Kotlin © RapidValue Solutions 2 Extent Report Generation with Kotlin  Pre-requisites Following are the pre-requisites to generate Extent reports with Kotlin:  Install Java SDK 8 and above.  Install Eclipse or IntelliJ IDEA IDEs.  Install the Kotlin plugin in IDEs. Here, we are using Eclipse as IDE and Kotlin plugin for Eclipse downloaded from https://marketplace.eclipse.org/content/kotlin-plugin-eclipse.  The latest version of following maven dependencies: o testng o selenium-java o selenium-server o kotlin-test o kotlin-stdlib-jdk8 o extentreports  Step-by-step Procedure Step 1: Create a maven project and add the above dependencies in pom.xml of the project. Step 2: Create a Kotlin class to keep the logic to generate the Extent Report. Let say the class name is AutomationReport. Here, we are using ITestListener interface of TestNG to control the executions and results. Below is the code snippet of the AutomationReport class to implement the ITestListener and declare the objects for ExtentSparkReporter, ExtentReports, and ExtentTest, class AutomationReport : ITestListener { public lateinit var sparkReporter: ExtentSparkReporter public lateinit var extentReport: ExtentReports public lateinit var extentTest: ExtentTest …} Step 3: Create an override method onStart() with logic to generate an HTML template for the test report, override fun onStart(testContext: ITestContext) { try { sparkReporter = ExtentSparkReporter(System.getProperty(“user.dir”) + “/AutomationReport/”) sparkReporter.config().setDocumentTitle(“Kotlin Automation”) sparkReporter.config().setReportName(“Automation Execution Report”) sparkReporter.config().setTheme(com.aventstack.extentreports.reporter.configuration.Theme.DARK) extentReport = ExtentReports() extentReport.attachReporter(sparkReporter) extentReport.setSystemInfo(“Application Name”, “Kotlin Report Demo”)
  • 3. Guide to Generate Extent Report in Kotlin © RapidValue Solutions 3 extentReport.setSystemInfo(“Platform”, System.getProperty(“os.name”)) extentReport.setSystemInfo(“Environment”, “QA”) } catch (e: Exception) { e.printStackTrace() } } Step 4: Create an override method onTestStart() with logic to collect current test case name and add it to the report, override fun onTestStart(result: ITestResult) { var testName: String = result.getMethod().getMethodName() extentTest = extentReport.createTest(testName) } Step 5: Create an override method onTestSuccess() with logic to add pass status to the report, override fun onTestSuccess(result: ITestResult) { var testName: String = result.getMethod().getMethodName() try { extentTest.log( Status.PASS, MarkupHelper.createLabel(testName + ” Test Case PASSED”, ExtentColor.GREEN) ) } catch (e: Exception) { e.printStackTrace() } } Step 6: Create an override method onTestSkipped() with logic to add skip status to the report, override fun onTestSkipped(result: ITestResult) { var testName: String = result.getMethod().getMethodName() try { extentTest.log( Status.SKIP, MarkupHelper.createLabel(testName + ” Test Case SKIPPED”, ExtentColor.ORANGE) ) } catch (e: Exception) { e.printStackTrace() } } Step 7: Create an override method onTestFailure() with logic to add fail status to the report, override fun onTestFailure(result: ITestResult) { var driver: WebDriver var currentClass = result.getInstance() var testName: String = result.getMethod().getMethodName()
  • 4. Guide to Generate Extent Report in Kotlin © RapidValue Solutions 4 try { driver = (currentClass as AutomationBase).getDriverInstance() var screenshotPath = Utilities().screenshotCapture(driver, result.getName()) extentTest.log( Status.FAIL, MarkupHelper.createLabel(testName + ” Test Case FAILED”, ExtentColor.RED) ) extentTest.log( Status.FAIL, MarkupHelper.createLabel(“Reason for Failure: ” + result.getThrowable().toString(), ExtentColor.RED) ) extentTest.addScreenCaptureFromPath(screenshotPath) } catch (e: Exception) { e.printStackTrace() } } Step 8: Create an override method onFinish() with logic to store HTML report to the specified path and flush extent report instance, override fun onFinish(testContext: ITestContext) { try { extentReport.flush() val dateFormat = SimpleDateFormat(“dd-MMM-yyyy_HH-mm-ss”) val date = Date() val filePathdate: String = dateFormat.format(date).toString() var actualReportPath: String = System.getProperty(“user.dir”) + “/AutomationReport/” + “index.html” File(actualReportPath).renameTo( File( System.getProperty(“user.dir”) + “/AutomationReport/” + “Automation_Report_” + filePathdate + “.html” ) ) } catch (e: Exception) { e.printStackTrace() } } Step 9: Create another class called Utilities to keep common utility functions required for automation. Here, we just added one utility to capture the screenshot. In onTestFailure() method, we already used a method called screenshotCapture(). Below is the code snippet to capture the screenshot, fun screenshotCapture(driver: WebDriver, fileName: String): String { var destination: String = “” try { var scrFile = (driver as TakesScreenshot).getScreenshotAs(OutputType.FILE) var dateFormat = SimpleDateFormat(“yyyyMMddHHmmss”) var cal = Calendar.getInstance() var path = File(“Failure_Screenshots”).getAbsolutePath()
  • 5. Guide to Generate Extent Report in Kotlin © RapidValue Solutions 5 destination = path + “/” + fileName + dateFormat.format(cal.getTime()) + “.png” scrFile.copyTo(File(destination)) } catch (e: Exception) { e.printStackTrace() } return destination } Step 10: Prior to starting the automation execution, you have to map the AutomationReport class to your test runner class (the class which starting your driver instance within TestNG annotation). You can represent AutomationReport class in test runner class as below, @Listeners(AutomationReport::class) Step 11: Now, you can run your test cases using testng.xml and once execution complete the HTML report will generate inside the AutomationReport folder in the project structure. Following are some excerpts of the Extent Report: We hope you got an idea of the Extent Report implementation using Kotlin language. Try to use the above step-by-step procedure in your automation world and explore it.
  • 6. Guide to Generate Extent Report in Kotlin © RapidValue Solutions 6 Conclusion Kotlin is a general-purpose, open-source, statically typed programming language that combines object- oriented and functional programming features. So, it is a strong and powerful language that helps the automation engineers to write their automation scripts and also develop the Extent Report. This article helps the automation engineers to up skill and develop the extent reports using a different language like Kotlin. By, Sanoj S, Test Architect, RapidValue
  • 7. Guide to Generate Extent Report in Kotlin © RapidValue Solutions 7 About RapidValue RapidValue is a global leader in digital product engineering solutions including mobility, omni-channel, IoT, AI, RPA and cloud to enterprises worldwide. RapidValue offers its digital services to the world’s top brands, Fortune 1000 companies and innovative emerging start-ups. With offices in the United States, the United Kingdom, Germany and India and operations spread across the Middle-East, Europe and Canada, RapidValue delivers enterprise services and solutions across various industry verticals. Disclaimer: This document contains information that is confidential and proprietary to RapidValue Solutions Inc. No part of it may be used, circulated, quoted, or reproduced for distribution outside RapidValue. If you are not the intended recipient of this report, you are hereby notified that the use, circulation, quoting, or reproducing of this report is strictly prohibited and may be unlawful. www.rapidvaluesolutions.com/blogwww.rapidvaluesolutions.com +1 877.643.1850 contactus@rapidvaluesolutions.com