Hello, Does any of you able to implement Extent Cucumber reports in Katalon? I had tried it but so many problems appeared due to the version mismatches of the jar files I guess…Any help would be appreciated. Is it even possible? I didn’t see any other thread in google which talks about integration of Katalon with extent reports. Have tried the Extent report adapter and vimalselvam.com’s Extent report wrapper too, both of which failed in Katalon.
Any help or pointer is greatly appreciated.
Guys, any help on this would be appreciated please…
There is something new here:
A sample project is published here:
This sample explains much better than the page on Katalon Store. Have a look at this.
@rvipinkumar in this discussion and kmohit302 who have developed the plugin — I wonder if they are the same person or not.
Hi @kazurayam , I have implemented this and Extent report is working with Katalon but when i tried with Cucumber BDD then It is not working. Custom keywords do not support when i used the listner code given here in my step definition file. Can you help please? or guide here?
Hi there,
Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.
Thanks!
You should ask your question to @mohit.kumar, the originator of the plugin.
When you ask a question, you should disclose the logs you got and your code. Preferably you should make and publish a zip of runnable Katatalon project that could reproduce the problem so that @mohit.kumar and others can understand your problem on their machines.
You should describe what you expected to see (in the logs) and wha you actually saw. This will make it clear what you mean by saying “it does not work”.
Please note that Extent Reports is now an enterprise plugin and is no longer compatible with the free version of Katalon Studio.
How to Use the Extent Report Plugin with BDD
- Create a Separate Class for Your Extent Report Functions Define a class to manage your Extent Report functions.
import com.aventstack.extentreports.ExtentTest
import com.aventstack.extentreports.MediaEntityBuilder
import com.aventstack.extentreports.Status
import com.katalon.extent.report.ExtentReport
import com.kms.katalon.core.configuration.RunConfiguration
import internal.GlobalVariable
public class CommonFunctions {
public static String getExecutionSourceName = "TestCase"
public static void attachScreenshot() {
getExecutionSourceName = RunConfiguration.getExecutionSourceId()
if(getExecutionSourceName.startsWith("Test Suite")) {
String screenshotPath = ExtentReport.getScreenshot()
ExtentReport.extentTest.log(Status.PASS, 'Screenshot added.', MediaEntityBuilder.createScreenCaptureFromPath(screenshotPath).build())
}
}
public static void attachLog(String details) {
getExecutionSourceName = RunConfiguration.getExecutionSourceId()
if(getExecutionSourceName.startsWith("Test Suite")) {
ExtentReport.extentTest.log(Status.PASS, details)
}
}
}
- Call These Functions in Your Step Definitions Utilize the functions from
CommonFunctions
within your step definition files to generate logs and attach screenshots.
- Verify the Extent Report After executing your tests, verify that the Extent Report has accurately recorded the logs and screenshots.
@kazurayam Thanks for the reply and noted.
@mohit.kumar Thankyou for explaining the use of Extent report in detail.
I have created a separate class for using Extent report in Cucumber but I am getting unable to resolve class “import com.aventstack….”but I am able to “ import com.relevantcode….”
import com.kms.katalon.core.webui.exception.WebElementNotFoundException
import com.relevantcodes.extentreports.ExtentReports
import com.relevantcodes.extentreports.ExtentTest
import com.relevantcodes.extentreports.LogStatus as LogStatus
import com.aventstack.extentreports.ExtentTest
import com.aventstack.extentreports.MediaEntityBuilder
import com.aventstack.extentreports.Status
import com.katalon.extent.report.ExtentReport
import com.kms.katalon.core.configuration.RunConfiguration
When I check to uninstall and install plugin again from Katalon store and reload plugin then I got status error in reloading. But the plugin copied from your github sample demo project inside my plugin folder is working. So, please let me know how to proceed. I am a licensed user. Please let me know if you need more details.
Hi Mohit,
Thankyou for explaining the use of Extent report in detail.
I have created a separate class for using Extent report in Cucumber but I am getting unable to resolve class “import com.aventstack….”but I am able to “ import com.relevantcode….”
When I check to uninstall and install plugin again from Katalon store and reload plugin then I got below error. But the plugin copied from your github sample demo project inside my plugin folder is working. So, please let me know how to proceed. I am a licensed user. Please let me know if you need more details.
Could you please download the plugin from this link and add it to your project’s plugin folder?
extent-report-sample-all.jar (7.3 MB)
Hi Mohit,
I tried this and now I am not getting that “unable to resolve error” Error now but I am running test suite and it is giving below error. Also, Extent report is not generating.
Error:
Hi,
There are two separate functions available:
- To include a screenshot in your reports, use the following call:
CommonFunctions.attachScreenshot()
- To add a description, use this call:
CommonFunctions.attachLog('Add your description here')
1 Like
Listener Used:
class TestListenerExtentReport {
public static ExtentReports extent
public static ExtentTest extentTest
public static String execID
public static String testcasename
@BeforeTestSuite
def deleteHtmlReport() {
Path folderPath = Paths.get(RunConfiguration.getProjectDir()+"/Extent/");
try {
// Delete everything within the folder
deleteFolderContents(folderPath);
} catch (IOException e) {
e.printStackTrace();
}
//Files.deleteIfExists(Paths.get(RunConfiguration.getProjectDir()+"/Extent/"));
}
@BeforeTestCase
def sampleBeforeTestCase(TestCaseContext testCaseContext) {
execID = RunConfiguration.getExecutionSourceName()
String tcID = RunConfiguration.getExecutionSourceName().toString()
testcasename = testCaseContext.getTestCaseId().substring(testCaseContext.getTestCaseId().lastIndexOf('/') + 1)
extent = CustomKeywords.'com.katalon.plugin.keyword.extentReport.Extent.setupExtentReport'(execID)
extentTest = CustomKeywords.'com.katalon.plugin.keyword.extentReport.Extent.startExtentTest'(tcID+" : "+testcasename, 'Test Execution : '+testCaseContext.getTestCaseId(),
extent)
}
@AfterTestCase
def sampleAfterTestCase(TestCaseContext testCaseContext) {
WebDriver driver = DriverFactory.getWebDriver()
CustomKeywords.'com.katalon.plugin.keyword.extentReport.Extent.tearDownTest'(driver, extent, extentTest)
}
@AfterTestSuite
def sampleAfterTestSuite(TestSuiteContext testSuiteContext) {
}
public static void deleteFolderContents(Path folderPath) throws IOException {
Files.walkFileTree(folderPath, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file); // Delete files
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
if (exc == null) {
Files.delete(dir); // Delete directories
return FileVisitResult.CONTINUE;
} else {
throw exc;
}
}
});
}
}
Could you please try using the latest Test Listener code mentioned here?
1 Like
Hi Mohit,
Finally, I successfully exported the below extent report with events. Thanks for the response
Now, I only have few last queries related to the extent report as below:
`1. I have to write logs for each keyword for e.g “@And User login succssfully”, then to replicate this keyword in extent report I have to write log for each keyword to identify(“And User login succssfully “)in step defifiniton file. Why extent report not pick the feature file keywords automatically or I have to modified the common functions.
-
Do we have any common function to display JSPN respone in extent report for API test scripts.
-
When any test case failed then it does not shows the error which I mark in logs for e.g if something failed in if else statement then I put attachlog(“Failed”) but it display the error which neither in console or what I am expecting through logs. See below screentshot from report
Code used
For Point No 1: You can create a wrapper for the attachLog
function that utilizes Cucumber keywords and retrieves the step name using scenario.getName()
. Then, pass this value to the attachLog
function.
For Point No 2: You can directly pass the JSON response to the attachLog
function.
For Point No 3: Could you please provide more details?
1 Like
Hi Mohit,
Thanks for all the solution for Extent report integration with katalon. I am able to get extent report on local but when i execute it on azure pipeline then i am not getting auto generated Extent report folder. Do you have any update on this:
I am using below yaml file which successfully generates Katalon built-in reports in azure artifact when i use ‘Reports’ in PathtoPublish location but unable to get Extent report when i use ‘Extent’:
Do you have any solution for this?