0

@BeforeGroups and AfterGroups are throwing NullPointer Exception for each run.

I am running BeforeGroups with Syntax: @BeforeGroups(groups = "ICSInvoice") and testcases under it with Syntax: @Test(enabled = true, groups = "ICSInvoice")

It is failing at the first line of method with the below error :

Time elapsed: 333.578 sec <<< FAILURE! java.lang.NullPointerException: null

Error coming at the first line:

public void initializeMyGroup() throws Exception { 
    logger.info("Enable Prerequisite for realms"); 

Logs:

initializeMyGroup(com.buyer.tests.selenium2.UITests.ManageAc‌​countingTester)

Time elapsed: 333.578 sec <<< FAILURE!

java.lang.NullPointerException: null at com.buyer.tests.selenium2.UITests.ManageAccountingTester.ini‌​tializeMyGroup(Manag‌​eAccountingTester.ja‌​va:160)

160 is the above line: logger.info("Enable Prerequisite for realms");

juherr
  • 5,640
  • 1
  • 21
  • 63
rich
  • 61
  • 1
  • 1
  • 3
  • Could you share the stracktrace and the code from where the NPE comes? – juherr Feb 10 '17 at 08:19
  • Error coming at the first line: public void initializeMyGroup() throws Exception { logger.info("Enable Prerequisite for xyz"); – rich Feb 10 '17 at 09:24
  • So `logger` is null. – juherr Feb 10 '17 at 10:16
  • Error coming at the first line: public void initializeMyGroup() throws Exception { logger.info("Enable Prerequisite for realms"); Logs: initializeMyGroup(com.buyer.tests.selenium2.UITests.ManageAccountingTester) Time elapsed: 333.578 sec <<< FAILURE! java.lang.NullPointerException: null at com.buyer.tests.selenium2.UITests.ManageAccountingTester.initializeMyGroup(ManageAccountingTester.java:160) 160 is the above line: logger.info("Enable Prerequisite for realms"); – rich Feb 10 '17 at 10:19
  • but logger is working for other testcases, issue is coming only when it is in Before or After Group, Is the syntax is correct for the annotation? – rich Feb 10 '17 at 10:20
  • Please provide more details: how do you run the test? what are the options you use? what are the annotations on `initializeMyGroup`? where do you init the logger? ... – juherr Feb 10 '17 at 12:43

0 Answers0