title: Null pointer exception due to driver instance is null in onTestFailureMethod
body: <p>Need help on - I am getting null pointer exception in onTestFailure method. If any of my @Test method fails control goes to onTestFailure but driver is null in that method. my code is like - </p>
  
  <pre><code>import statements...
  @Listeners(ScreenShot.class)
  public class ScreenShot implements ITestListener{
      WebDriver driver;
      @BeforeClass
      public void launch(){
          System.setProperty("webdriver.ie.driver", "D:\\Jars\\Drivers\\IEDriverServer.exe");
          driver = new InternetExplorerDriver();
          driver.get("url");
      }
  
      @Test
      public void test1(){
          //driver.findElement(By.id("Email")).sendKeys("E@E.COM");
          System.out.println("Method1 begins");
          //some code here - exception occurs here
          System.out.println("Method ended");
      }
  
      public void onTestFailure(ITestResult result){
          File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);  //Getting exception here as driver is null
          try {
              FileUtils.copyFile(scrFile, new File("C:\\snaps\\"+result.getMethod().getMethodName()+".png"));
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } 
      }
  </code></pre>
  
  <p>i am running this class by right click->run as testng. </p>