Getting a null Pointer when i execute the testNG.xml from commandLine if i have extent reports 3.0.6 intergrated
public void beforeSuite() throws Exception {
/**
* Initiate the Extent Report
*/
Log.info("Initializing and creating report Now");
extent = ExtentManager.createInstance("output/reports/extent.html");
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("output/reports/extent.html");
extent.setSystemInfo("Environment","Night Run");
extent.setSystemInfo("Selenium version", "v2.53.0");
extent.setSystemInfo("Test Environment", "v2.53.0");
extent.attachReporter(htmlReporter);
// End of Report Intialisation
}
@BeforeClass
public void setup() throws FileNotFoundException {
Log.info("Running Before Class");
/**
* Report class Parent Node Generation
*/
Log.info("Initializing and Parent Level of the Test in the Report");
ExtentTest parent = extent.createTest(getClass().getName());
parent.assignAuthor("Ivan Katumba");
parentTest.set(parent);
}
@BeforeMethod(alwaysRun = true)
public void before(Method method, ITestResult result ,ITestContext iTestContext) throws Exception {
Test testparams = method.getAnnotation(Test.class);
/**
* Addning the Child to the Parent Node on the Extent Report
*/
Log.info("Initializing the child on the Test in the Report");
child = ((ExtentTest) parentTest.get()).createNode(testparams.testName());
child.assignCategory(testparams.groups());
Log.info("Adding the Author of the report");
test.set(child);
}
@AfterMethod(alwaysRun = true)
public void after(ITestResult result , final ITestContext testContext , Method method) throws IOException {
if (result.getStatus() == ITestResult.FAILURE) {
((ExtentTest) test.get()).fail(result.getThrowable());
TestCaseName = testparams.testName();
long time = result.getEndMillis() - result.getStartMillis();
int minutes = (int) ((time / 1000) / 60);
child.log(Status.INFO, "Execution Time was : "+String.valueOf(minutes));
String res = captureScreenshot(driver);
TestCaseName = testparams.testName();
Log.info("Capturing a screen Shoot for the Failed Test");
((ExtentTest) test.get()).addScreenCaptureFromPath(res);
}
else if (result.getStatus() == ITestResult.SKIP) {
((ExtentTest) test.get()).skip(result.getThrowable());
TestCaseName = testparams.testName();
long time = result.getEndMillis() - result.getStartMillis();
int minutes = (int) ((time / 1000) / 60);
child.log(Status.INFO, "Execution Time was : "+String.valueOf(minutes));
}else if(result.getStatus()==ITestResult.SUCCESS) {
Log.info("Congrats : Your Test Passed");
TestCaseName = testparams.testName();
long time = result.getEndMillis() - result.getStartMillis();
int minutes = (int) ((time / 1000) / 60);
child.log(Status.INFO, "Execution Time was : "+String.valueOf(minutes));
((ExtentTest) test.get()).pass("Test passed");
}
Log.info("Saving the Report Now:");
extent.flush();
}
My Test is
@Test(testName = "Generate Report",groups={"Regressing"},dataProvider = "updateCard")
public void genreport(Integer id , String name ) throws Throwable {
extentLog("Varidating the Data Provider");
System.out.println("The id is "+ id + " and the name is : "+ name);
Assert.assertEquals("7","y");
}
Getting a null Pointer when i execute the testNG.xml from commandLine if i have extent reports 3.0.6 intergrated
@BeforeClass public void setup() throws FileNotFoundException {
@BeforeMethod(alwaysRun = true) public void before(Method method, ITestResult result ,ITestContext iTestContext) throws Exception {
@AfterMethod(alwaysRun = true) public void after(ITestResult result , final ITestContext testContext , Method method) throws IOException {
if (result.getStatus() == ITestResult.FAILURE) {
}
My Test is
@Test(testName = "Generate Report",groups={"Regressing"},dataProvider = "updateCard") public void genreport(Integer id , String name ) throws Throwable {
TestNg file
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">