title: How does a constructor work in a TestNG class inheriting from a parent java class
body: <p>In testng class, I have a constructor with following methods 
  super(driver) - this calls parent class and passes driver object 
  setup() - this call goes to parent class,where a new driver object is created</p>
  
  <p>Eg code</p>
  
  <pre><code>public class LoginTestNG extends ProjectTestBase {
  
    WebDriver driver;  
    static By locator = By.name("airline");
  
  
  
    public LoginTestNG(WebDriver driver) {
        super(driver);
        System.out.println("I am in constructor");
        setup();
  
    }  
  
  
  
    @Test(dataProvider = "logn")
    public static void login_with_valid_user_param(String uname, String passwd){  
        LoginActions.submit_login(uname,passwd);      
    }
  
    @DataProvider(name = "logn")
    public static Object[][] loginData(){
  
        return new Object[][]{{"test","test"}};
    }
  
  }
  </code></pre>
  
  <p>Parent class code:</p>
  
  <pre><code>public class ProjectTestBase{
  
    public LoginActions loginActions;
      static LoginPage loginPage;
      public static WebDriver driver;
      public ProjectTestBase(WebDriver driver){               
          this.driver=driver;     
      }
  
  
    public static void setup(){
        driver = startBrowser("firefox");
        createActions(driver);
        createPages(driver);
        launchURL("http://newtours.demoaut.com/index.php");
        driver.manage().window().maximize();
    }
  
    public static void createActions(WebDriver driver){
        loginActions = new com.newtours.actions.LoginActions(driver);
    }
  
    public static void createPages(WebDriver driver){
        loginPage = new LoginPage(driver);
    }
  }
  </code></pre>
  
  <p>my question is: 
  1. This code works fine if i run the test in a java class
  2. If I add the test to a testNG class it does not work, I mean, I am getting<br>
  null pointer exception because driver object is null. I think the constructor is not getting invoked, I need help to understand if the constructor works differently in a testng class.</p>
  
  <p>Thanks
  sk</p>