2013-10-25 39 views
-1

我在一個maven項目中使用testng進行selenium自動化測試。 我想爲testng定義一個xml文件,以在POM.xml中運行,但它不起作用。請幫忙!如何在maven中設置POM.xml

這裏是我的pom.xml文件

 <dependencies> 
      <dependency> 
       <groupId>org.testng</groupId> 
       <artifactId>testng</artifactId> 
       <version>6.3.1</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.seleniumhq.selenium</groupId> 
       <artifactId>selenium-java</artifactId> 
       <version>2.33.0</version> 
      </dependency> 
     </dependencies> 


     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <configuration> 
         <source>1.5</source> 
         <target>1.5</target> 
       </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 

        <version>2.12.4</version> 
         <configuration> 
          <suiteXmlFiles> 
           <suiteXmlFile>src/test/resource/testng.xml</suiteXmlFile> 
          </suiteXmlFiles> 
         </configuration> 
        </plugin>  
       </plugins> 
      </build> 


</project> 
+0

首先,你要使用的插件的所有定義,是不完整的 - 沒有任何的artifactId。 – Mareen

+0

在標籤suiteXMLFile之前,我添加 maven-surefire-plugin,但它沒有工作 –

回答

-1
This is how it should look like 

<plugins> 
    [...] 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.16</version> 
     <configuration> 
      <suiteXmlFiles> 
      <suiteXmlFile>Src/test/resources/testng.xml</suiteXmlFile> 
      </suiteXmlFiles> 
     </configuration> 
     </plugin> 
    [...] 
</plugins> 
+0

我嘗試http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html,但是當項目運行時它會自動生成一個臨時的xml文件 –