Open sanmativardhaman opened 6 years ago
As you are creating reports.StartTest for each test meaning each method will be treated as a test. In this case, Try creating logger =reports.StartTest("tc_01") in a @beforeMethod and @aftermethod in baseclass
@BeforeMethod()
public void setupExtentTest(Method result)
{
// result.getName() = name of the test method executing
logger =reports.StartTest(result.getName())
}
@afterMethod()
public void teardown(ITestResult result)
{
//result.getname() = name of the test method executing
reports.endTest(result.getname());
reports.flush();
}
@aftermethod will declare your testcase finished and it will close that extenttest instance. in @aftersuite you will close the report and flush the report.
I hope this will help.
Even I am also facing the same problem. ExtentReports report; ExtentTest logger;
Note: When I change BeforeSuite to BeforeMethod i.e initialization of
Also I am using Aftermethod to Flush the report and quit driver. Any solution?
I am also facing the same issue.. Found any solution for this?
@anshooarora Please help to resolve this.
i have created a Base test class, which has all declarations w.r.t Extent reports,
i,e public class BaseTest { public WebDriver driver; public ExtentReports reports; public ExtentTest logger; public WebDriverWait wait; public WebElement myElement; public static Calendar c = Calendar.getInstance();
ExtentReports(System.getProperty("user.dir")+"\Reports\"+dateStamp()+"\"+"API_SmokeTest.html"); }
}. i have two test classes which extends this base test. In test class one and two i have created logger object i,e logger =reports.StartTest("tc_01") Test class one runs fine, In test class two also i have same line, i,e logger =reports.startTest("tc_02"), when i run my testng.xml, only first testng class is executing while the second class throws 'null pointer exception" for this line logger =reports.startTest("tc_02"). Kindly help