title: TestNG test skips while executing it inside servlet
body: <p>I am trying to Execute TestNG test inside servlet with the help of "<a href="http://testng.org/javadoc/org/testng/TestListenerAdapter.html" rel="nofollow">TestListenerAdapter</a>" and "<a href="http://testng.org/javadoc/org/testng/TestNG.html" rel="nofollow">TestNG</a>" my code snippet is like this:</p>
  
  <pre><code>TestListenerAdapter tla = new TestListenerAdapter();
  TestNG testng = new TestNG();
  testng.setTestClasses(new Class[] {src.scriptDemo.LoginTest.class});
  testng.addListener(tla);
  testng.run();
  </code></pre>
  
  <p>So, When i am executing this code snippet inside a Java Program the test name "LoginTest" is executing successfully (i.e. test starts, browsers opens and whole test executes).
  But when the same code runs inside a Servlet it gives:</p>
  
  <pre><code>[TestNG] Running:
    Command line suite
  
  
  ===============================================
  Command line suite
  Total tests run: 1, Failures: 0, Skips: 1
  Configuration Failures: 1, Skips: 1
  ===============================================
  </code></pre>
  
  <p>It seems like test starts to execute but skipped. I don't know the reason behind this. </p>
  
  <p>PS: I debug my code and found that, It skips test due to FirefoxDriver() in the LoginTest selenium script file. Code of LoginTest.java is:</p>
  
  <pre><code>package src.scriptDemo;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  import org.testng.annotations.AfterTest;
  import org.testng.annotations.BeforeTest;
  import org.testng.annotations.Test;
  
  public class LoginTest {
  
      WebDriver driver;
      String baseUrl;
      @BeforeTest
      public void setupSelenium() {
          driver = new FirefoxDriver(true);
          baseUrl = "https://example.com/login";
          System.out.println("1:");
      }
  
      @Test
      public void testCsrLogin() {
          driver.get(baseUrl);
          System.out.println("2:");
          driver.findElement(By.id("username")).sendKeys("blah");
          driver.findElement(By.id("password")).sendKeys("blah");
          driver.findElement(By.className("btn-primary")).click();
      }
  
      @AfterTest
      public void closeSelenium() {
              System.out.println("3:");
              driver.close();
              driver.quit();
      }
  }
  </code></pre>
  
  <p>But while executing again by commenting FirefoxDriver(), the test runs without any problem and gives output</p>
  
  <pre><code>Total tests run: 1, Failures: 1, Skips: 0
  </code></pre>
  
  <p>Can anyone suggest whats going on here and how to solve it, 
  Please let me know if more description is required.</p>
  
  <p>Thanks in Advance</p>