2017-04-12 88 views
0

有人可以幫助我嗎?我目前有兩個錯誤。文件配置文件上的<profiles>以及底部的</project>。如果有人能夠幫助我,我將不勝感激。用TestNG構建Maven

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>Finance</groupId> 
    <artifactId>MavenTestNGpaytm</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

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

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

    <profiles> 
     <profile> 
     <id>Class</id> 
      <build> 

    <plugins> 
    <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.19.1</version> 
       <configuration> 
       <suiteXmlFiles> 
       <suiteXmlFile>Class.xml</suiteXmlFile> 
        </suiteXmlFiles> 
       </configuration> 
    </plugin> 

     <profiles> 
      <profile> 
       <id>Package</id> 
        <build> 

    <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.19.1</version> 
       <configuration> 
        <suiteXmlFiles> 
       <suiteXmlFile>Package.xml</suiteXmlFile> 
       </suiteXmlFiles> 
       </configuration> 
       </plugin> 

       </build> 
       </profile> 
       </profiles>   

    <dependencies> 

    <dependency> 
     <groupId>org.testng</groupId> 
     <artifactId>testng</artifactId> 
     <version>6.9.8</version> 
     <scope>test</scope> 
    </dependency> 

<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-java</artifactId> 
    <version>3.3.1</version> 
</dependency> 
     <dependency> 
    <groupId>io.appium</groupId> 
    <artifactId>java-client</artifactId> 
    <version>2.1.0</version> 
</dependency> 
</dependencies> 
</project> 
+2

嗨,你能描述哪些錯誤是你得到的?我問,因爲你發佈在問題中的'pom.xml'根本無效(從XML的角度來看)!例如,根本沒有關閉''。 – danidemi

回答

1

請檢查以下內容;有一些開放的XML標籤需要適當關閉:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>Finance</groupId> 
    <artifactId>MavenTestNGpaytm</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

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

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

    <profiles> 
     <profile> 
      <id>Class</id> 
      <build> 


       <plugins> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-surefire-plugin</artifactId> 
         <version>2.19.1</version> 
         <configuration> 
          <suiteXmlFiles> 
           <suiteXmlFile>Class.xml</suiteXmlFile> 
          </suiteXmlFiles> 
         </configuration> 
        </plugin> 
       </plugins> 

      </build> 
     </profile> 

     <profile> 
      <id>Package</id> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-surefire-plugin</artifactId> 
         <version>2.19.1</version> 
         <configuration> 
          <suiteXmlFiles> 
           <suiteXmlFile>Package.xml</suiteXmlFile> 
          </suiteXmlFiles> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 

    <dependencies> 

     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>6.9.8</version> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>3.3.1</version> 
     </dependency> 
     <dependency> 
      <groupId>io.appium</groupId> 
      <artifactId>java-client</artifactId> 
      <version>2.1.0</version> 
     </dependency> 
    </dependencies> 
</project> 
+0

謝謝。它工作得很好 – Tessy

+0

嗨@tutuade如果以前的答案回答你的問題,這將是很好的從你選擇它作爲正確的答案。 – danidemi