使用TestNG构建Maven

时间:2017-04-12 21:01:22

标签: maven

是的,有人能帮帮我吗?我目前有两个错误。文件个人资料中为<profiles>,底部为</project>。如果有人可以帮助我,我将不胜感激。

<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>

1 个答案:

答案 0 :(得分:2)

请在下面查看;有一些开放的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>