Comment appeler testng.xml fichier de pom.xml dans Maven

Je suis en utilisant Selenium WebDriver, Eclipse, TestNG et plugin Surefire. Je ne suis pas en mesure d'exécuter testng.xml fichier de pom.xml. Alors que je suis en cours d'exécution pom.xml à l'aide de mvn test il permet d'exécuter directement le fichier qui est dans le src/test/java.

mon pom.xml le code est

<groupId>angel</groupId>
<artifactId>Angel</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Angel</name>  
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>   </properties>

<dependencies>
          <!-- Java API to access the Client Driver Protocols -->
 <dependency>
     <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.21.0</version>
 </dependency>
  <!-- JExcel API is a java library which provides the ability to read, write, and                 modify Microsoft Excel spreadsheets.-->
  <dependency>
     <groupId>net.sourceforge.jexcelapi</groupId>
    <artifactId>jxl</artifactId>
    <version>2.6.10</version>
    </dependency>
   <dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.14</version>
</dependency>
 <!-- Java API for manipulate the Microsoft Excel Sheets.  -->  
 <dependency>  
<groupId>org.apache.poi</groupId>  
<artifactId>poi-contrib</artifactId> 
 <version>3.5-beta5</version>   
 </dependency>
 <!-- Java Mail API used to send Mails. -->   <dependency>             <groupId>javax.mail</groupId> 
 <artifactId>mail</artifactId>   <version>1.4.3</version>
</dependency>
<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.3.1</version>
  <scope>test</scope>
</dependency>
 </dependencies>  
  <build>  
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugin</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12</version>
          <configuration>
           <suiteXmlFiles>
               <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
          </suiteXmlFiles>
                 </configuration> 
    </plugin>
 <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
             <source>1.6</source>
            <target>1.6</target>
         </configuration>        </plugin> 

</plugins> 
   </project>

S'il vous plaît aider moi.

Mon projet de la structure est

 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

-- =>les noms de dossier
|-- =>sous les noms de dossier

Mon testng.xml fichier est...

  <?xml version="1.0" encoding="UTF-8"?>
  <suite name="Suite1" verbose="1"  >

 <test name="samplePage Test" >
   <classes>
   <class name="TestScripts.SamplePage" >
        <methods>
            <include name = "SamplePageTest_Execution"/>
        </methods>
    </class>
</classes>
 </test>
   <test name="newSamplePage Test" >
    <classes>
   <class name="TestScripts.NewSamplePage" >
        <methods>
            <include name = "NewSamplePage_Execution02"/>
        </methods>
        </class>
    </classes>
   </test> 
 </suite>

je voulais juste appeler la SamplePage_Execution méthode de pom.xml par le biais de testng.xml fichier.

Mon SamplePage_Execution méthode est

  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();
}}
Mon code suivant ne fonctionne pas: <configuration> <suiteXmlFiles> <suiteXmlFile>testng.xml</suiteXmlFile> </suiteXmlFiles> </configuration> Le code ci-dessous a bien fonctionné: <configuration> <comprend> <include>**/*ST.java</include> </includes> </configuration> Note: Mon sélénium java nom de code est: Selenium2ExampleST.java

OriginalL'auteur Manigandan | 2012-05-10