title: How to call testng.xml file from pom.xml in Maven
body: <p>I'm using Selenium WebDriver, Eclipse, TestNG and Surefire plugin. I am not able to run testng.xml file from pom.xml. While I'm running pom.xml using <strong>mvn test</strong> it directly run the file which is in the <strong>src/test/java</strong>.</p>
  
  <p>my pom.xml code is </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;groupId&gt;angel&lt;/groupId&gt;
  &lt;artifactId&gt;Angel&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  &lt;name&gt;Angel&lt;/name&gt;  
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
  &lt;properties&gt;
  &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;   &lt;/properties&gt;
  
  &lt;dependencies&gt;
            &lt;!-- Java API to access the Client Driver Protocols --&gt;
   &lt;dependency&gt;
       &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
      &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;
      &lt;version&gt;2.21.0&lt;/version&gt;
   &lt;/dependency&gt;
    &lt;!-- JExcel API is a java library which provides the ability to read, write, and                 modify Microsoft Excel spreadsheets.--&gt;
    &lt;dependency&gt;
       &lt;groupId&gt;net.sourceforge.jexcelapi&lt;/groupId&gt;
      &lt;artifactId&gt;jxl&lt;/artifactId&gt;
      &lt;version&gt;2.6.10&lt;/version&gt;
      &lt;/dependency&gt;
     &lt;dependency&gt;
    &lt;groupId&gt;log4j&lt;/groupId&gt;
    &lt;artifactId&gt;log4j&lt;/artifactId&gt;
    &lt;version&gt;1.2.14&lt;/version&gt;
  &lt;/dependency&gt;
   &lt;!-- Java API for manipulate the Microsoft Excel Sheets.  --&gt;  
   &lt;dependency&gt;  
  &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;  
  &lt;artifactId&gt;poi-contrib&lt;/artifactId&gt; 
   &lt;version&gt;3.5-beta5&lt;/version&gt;   
   &lt;/dependency&gt;
   &lt;!-- Java Mail API used to send Mails. --&gt;   &lt;dependency&gt;             &lt;groupId&gt;javax.mail&lt;/groupId&gt; 
   &lt;artifactId&gt;mail&lt;/artifactId&gt;   &lt;version&gt;1.4.3&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.testng&lt;/groupId&gt;
    &lt;artifactId&gt;testng&lt;/artifactId&gt;
    &lt;version&gt;6.3.1&lt;/version&gt;
    &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
   &lt;/dependencies&gt;  
    &lt;build&gt;  
  &lt;plugins&gt;
      &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugin&lt;/groupId&gt;
          &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.12&lt;/version&gt;
            &lt;configuration&gt;
             &lt;suiteXmlFiles&gt;
                 &lt;suiteXmlFile&gt;src/test/resources/testng.xml&lt;/suiteXmlFile&gt;
            &lt;/suiteXmlFiles&gt;
                   &lt;/configuration&gt; 
      &lt;/plugin&gt;
   &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
               &lt;source&gt;1.6&lt;/source&gt;
              &lt;target&gt;1.6&lt;/target&gt;
           &lt;/configuration&gt;        &lt;/plugin&gt; 
  
  &lt;/plugins&gt; 
     &lt;/project&gt;
  </code></pre>
  
  <p>Please help me.</p>
  
  <p>My project structure is </p>
  
  <pre><code> project
  --src/main/java
  --src/main/resources
  --src/test/java
      |
       --my testng class file with @Test method.
  --src/test/resources
       |
        --testng.xml
  --maven dependencies
  --jre system library
  --src
     |
      --main
      --test
  --target
  pom.xml
  </code></pre>
  
  <p>--   =>folder names
  |--  =>sub folder names</p>
  
  <p>My testng.xml file is...</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;suite name="Suite1" verbose="1"  &gt;
  
   &lt;test name="samplePage Test" &gt;
     &lt;classes&gt;
     &lt;class name="TestScripts.SamplePage" &gt;
          &lt;methods&gt;
              &lt;include name = "SamplePageTest_Execution"/&gt;
          &lt;/methods&gt;
      &lt;/class&gt;
  &lt;/classes&gt;
   &lt;/test&gt;
     &lt;test name="newSamplePage Test" &gt;
      &lt;classes&gt;
     &lt;class name="TestScripts.NewSamplePage" &gt;
          &lt;methods&gt;
              &lt;include name = "NewSamplePage_Execution02"/&gt;
          &lt;/methods&gt;
          &lt;/class&gt;
      &lt;/classes&gt;
     &lt;/test&gt; 
   &lt;/suite&gt;
  </code></pre>
  
  <p>i just wanted to call the SamplePage_Execution method from pom.xml through testng.xml file.</p>
  
  <p>My SamplePage_Execution method is </p>
  
  <pre><code>  public class sample{
    @Test
    public static void SamplePageTest_Execution() throws Exception{
  
  String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
  boolean testStatus = true;
         driver = new FirefoxDriver();
        driver.get("http://www.google.com"); 
  
     WebElement searchField = driver.findElement(By.name("q")); 
  
      searchField.sendKeys(new String [] {"selenium2.0"});
  
      searchField.submit();
  
      driver.close();
  }}
  </code></pre>