Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extentreport not generating in java when test executed using testNG #408

Open
reshma-sabu opened this issue Sep 15, 2023 · 0 comments
Open

Comments

@reshma-sabu
Copy link

I am trying to run a Java test and create a extentreport using Listener class, base class and test class.

BaseTest.class

package qatarlivestock.pagefactory.utils;

import java.io.FileInputStream;

import java.io.IOException;

import java.net.URL;

import java.time.Duration;

import java.util.Properties;

import org.testng.annotations.AfterClass;

import org.testng.annotations.BeforeClass;

import io.appium.java_client.android.AndroidDriver;

import io.appium.java_client.android.options.UiAutomator2Options;

import io.appium.java_client.service.local.AppiumDriverLocalService;

public class BaseTest {

public AndroidDriver driver;



public AppiumDriverLocalService service;

@BeforeClass

public void configAppium() throws IOException{


	Properties prop = new Properties();

	FileInputStream fis = new FileInputStream(System.getProperty("user.dir")+"//src//main//java//qatarlivestock//testdata//data.properties");

	prop.load(fis);

	String ipAddress = prop.getProperty("ipAddress");

	String deviceName = prop.getProperty("deviceName");

	UiAutomator2Options options = new UiAutomator2Options();

	options.setDeviceName(deviceName);
	
	options.setApp(System.getProperty("user.dir")+"//src//test//java//qatarlivestock//testresources//app-qa-release_Sep11.apk");

	driver = new AndroidDriver(new URL(ipAddress), options);

    driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

}

@AfterClass

public void tearDown() {

	driver.quit();

}

}

Listeners.class

package qatarlivestock.pagefactory.utils;

import java.io.FileInputStream;

import java.io.IOException;

import java.net.URL;

import java.time.Duration;

import java.util.Properties;

import org.testng.annotations.AfterClass;

import org.testng.annotations.BeforeClass;

import io.appium.java_client.android.AndroidDriver;

import io.appium.java_client.android.options.UiAutomator2Options;

import io.appium.java_client.service.local.AppiumDriverLocalService;

public class BaseTest {

public AndroidDriver driver;



public AppiumDriverLocalService service;

@BeforeClass

public void configAppium() throws IOException{


	Properties prop = new Properties();

	FileInputStream fis = new FileInputStream(System.getProperty("user.dir")+"//src//main//java//qatarlivestock//testdata//data.properties");

	prop.load(fis);

	String ipAddress = prop.getProperty("ipAddress");

	String deviceName = prop.getProperty("deviceName");

	UiAutomator2Options options = new UiAutomator2Options();

	options.setDeviceName(deviceName);
	
	options.setApp(System.getProperty("user.dir")+"//src//test//java//qatarlivestock//testresources//app-qa-release_Sep11.apk");

	driver = new AndroidDriver(new URL(ipAddress), options);

    driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

}

@AfterClass

public void tearDown() {

	driver.quit();

}

}

ExtentreporterNG.class

package qatarlivestock.pagefactory.utils;

import com.aventstack.extentreports.ExtentReports;

import com.aventstack.extentreports.reporter.ExtentSparkReporter;

public class ExtentReporterNG {

static ExtentReports extent;

public static ExtentReports getReporterObject()

{

	String path = System.getProperty("user.dir")+"//testreports//result.html";

	ExtentSparkReporter reporter=new ExtentSparkReporter(path);

	reporter.config().setReportName("Android Test Automation Result");

	reporter.config().setDocumentTitle("Test Results");
	
	extent = new ExtentReports();

	extent.attachReporter(reporter);

	extent.setSystemInfo("Tester", "Reshma");

	return extent;

}

}

SuccessfullLoginTest.class

package qatarlivestock.testcases;

import org.testng.annotations.Test;

import qatarlivestock.pagefactory.android.SuccessfullLoginElements;

import qatarlivestock.pagefactory.utils.BaseTest;

public class SuccessfullLoginTest extends BaseTest{

@Test

public void successfullLoginValidation() throws InterruptedException

{

	SuccessfullLoginElements login = new SuccessfullLoginElements(driver);

	login.clickloginbtn();

}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant