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;

@BeforeSuite
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”)
extent
.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"));
}

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

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

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

@AfterMethod
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
extent.endTest(logger);
}
@AfterTest
public void endReport(){
// writing everything to document
//flush() - to write or update test information to your report.
extent.flush();
//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
extent.close();
}

}


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

@Test(priority=1)
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.PLATFORM_NAME,MobilePlatform.ANDROID);

	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("http://127.0.0.1:4723/wd/hub"),cap );

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

	System.out.println(driver.getContext());
	
	
	Set<String> s=driver.getContextHandles();

	for(String handle : s)
	

	{

	System.out.println(handle);
	
	

	}
	driver.context("WEBVIEW_com.photon.metlifepol");
	System.out.println(driver.getContext());
	//switchToWebAppContext();
	//System.out.println(driver.getContext());

}
@Test(priority=2)
public void maintaincemessages() throws InterruptedException {
Thread.sleep(5000);
driver.findElementByXPath("//*[@id=“errorBtn1”]").click();
String str1=driver.findElementByXPath("//div[2]/ul/li[1]/div/div/p[@class=‘ng-binding’]").getText();
System.out.println(“message1:”+str1);

driver.findElementByXPath("//html/body/div[1]/section/div[3]/span/button[2]").click();
String str2=driver.findElementByXPath("//ul/ li[2]/div/div/p[@class='ng-binding']").getText();
System.out.println("message2:"+str2);
driver.findElementByXPath("//div[3]/span/button[2][@class='btn-arrow-next']").click();
String str3=driver.findElementByXPath("//ul/li[3]/div/div/p[@class='ng-binding']").getText();
System.out.println("message2:"+str3);
driver.findElementByXPath("//section/div[1]/a/img[@src='images/close-icon.svg']").click();

}

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.