Extent reports for appium

Im trying for Extent reports for my automation test cases. I have created Extent reporters class and i have a my test cases in another class prioritized with TestNg annotations.

import java.io.File;

import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;

public class ExtentReportsClass{
ExtentReports extent;
ExtentTest logger;

public void startReport(){
//ExtentReports(String filePath,Boolean replaceExisting)
//filepath - path of the file, in .htm or .html format - path where your report needs to generate.
//replaceExisting - Setting to overwrite (TRUE) the existing file or append to it
//True (default): the file will be replaced with brand new markup, and all existing data will be lost. Use this option to create a brand new report
//False: existing data will remain, new tests will be appended to the existing report. If the the supplied path does not exist, a new file will be created.
extent = new ExtentReports (System.getProperty(“user.dir”) +"/test-output/STMExtentReport.html", true);
//extent.addSystemInfo(“Environment”,“Environment Name”)
.addSystemInfo(“Host Name”, “Automation Report”)
.addSystemInfo(“Environment”, “QA”)
.addSystemInfo(“User Name”, “Mahesh”);
//loading the external xml file (i.e., extent-config.xml) which was placed under the base directory
//You could find the xml file below. Create xml file in your project and copy past the code mentioned below
extent.loadConfig(new File(System.getProperty(“user.dir”)+"\extent-config.xml"));

public void passTest(){
//extent.startTest(“TestCaseName”, “Description”)
//TestCaseName – Name of the test
//Description – Description of the test
//Starting test
logger = extent.startTest(“passTest”);
//To generate the log when the test case is passed
logger.log(LogStatus.PASS, “Test Case Passed is passTest”);

public void failTest(){
logger = extent.startTest(“failTest”);
logger.log(LogStatus.PASS, “Test Case (failTest) Status is passed”);

public void skipTest(){
logger = extent.startTest(“skipTest”);
throw new SkipException("Skipping - This is not ready for testing ");

public void getResult(ITestResult result){
if(result.getStatus() == ITestResult.FAILURE){
logger.log(LogStatus.FAIL, "Test Case Failed is "+result.getName());
logger.log(LogStatus.FAIL, "Test Case Failed is "+result.getThrowable());
}else if(result.getStatus() == ITestResult.SKIP){
logger.log(LogStatus.SKIP, "Test Case Skipped is "+result.getName());
// ending test
//endTest(logger) : It ends the current test and prepares to create HTML report
public void endReport(){
// writing everything to document
//flush() - to write or update test information to your report.
//Call close() at the very end of your session to clear all resources.
//If any of your test ended abruptly causing any side-affects (not all logs sent to ExtentReports, information missing), this method will ensure that the test is still appended to the report with a warning message.
//You should call close() only once, at the very end (in @AfterSuite for example) as it closes the underlying stream.
//Once this method is called, calling any Extent method will throw an error.
//close() - To close all the operation


after execution of my test cases im not able to see the extent report for my test cases

public void prepval() throws MalformedURLException, InterruptedException {

	// TODO Auto-generated method stub
	File appDir = new File("src/main/java");

	File app = new File(appDir, "QA_build_3.apk");

	DesiredCapabilities cap=new DesiredCapabilities();


	cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android device");
	cap.setCapability("autoGrantPermissions", true);
	cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "10000");
	//cap.setCapability("language", "JP");

	cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

	 driver=new AndroidDriver<AndroidElement>(new URL(""),cap );

	driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

	Set<String> s=driver.getContextHandles();

	for(String handle : s)




public void maintaincemessages() throws InterruptedException {
String str1=driver.findElementByXPath("//div[2]/ul/li[1]/div/div/p[@class=‘ng-binding’]").getText();

String str2=driver.findElementByXPath("//ul/ li[2]/div/div/p[@class='ng-binding']").getText();
String str3=driver.findElementByXPath("//ul/li[3]/div/div/p[@class='ng-binding']").getText();


i want to see the extent report for these two test cases, can anyone suggest me how to get extent report my test cases.

This is a good tutorial I found by googling ‘Extent reports’:

Seems like you need to create TestNg listeners & such. Full disclosure, I don’t use Extent Reports, but this looks like a pretty complete tutorial.