Java maven配置文件不执行测试

Java maven配置文件不执行测试,java,maven,selenium,jenkins,qa,Java,Maven,Selenium,Jenkins,Qa,我在使用maven命令运行测试时遇到问题。我到处都找了,但似乎没有一个解决方案能解决我的问题。我已经为我希望执行的测试创建了一个xml文件,我可以通过在testNG中运行它来实现这一点。我在项目的POM中创建了一个概要文件,但似乎无法让它实际运行测试,它只是构建然后结束。要运行的测试是Selenium测试 我使用的命令是“mvnverify-p{TestXml}” 个人资料如下所示 <profile> <id>BVT</id> <ac

我在使用maven命令运行测试时遇到问题。我到处都找了,但似乎没有一个解决方案能解决我的问题。我已经为我希望执行的测试创建了一个xml文件,我可以通过在testNG中运行它来实现这一点。我在项目的POM中创建了一个概要文件,但似乎无法让它实际运行测试,它只是构建然后结束。要运行的测试是Selenium测试

我使用的命令是“mvnverify-p{TestXml}”

个人资料如下所示

<profile>
     <id>BVT</id>
     <activation>
       <activeByDefault>true</activeByDefault>
     </activation>
     <build>
       <plugins>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-surefire-plugin</artifactId>
           <configuration>
             <includes>
               <include>src/main/resources/{folder}/{TestXml}.xml</include>
             </includes>
           </configuration>
         </plugin>
       </plugins>
     </build>
   </profile>

BVT
真的
org.apache.maven.plugins
maven surefire插件
src/main/resources/{folder}/{TestXml}.xml

我认为您的命令和pom.xml中存在一些问题

1) 配置文件名后面应该跟“-p”,我认为命令应该是mvn test-p BVT,而不是{testxml}

2) 在pom.xml中要使用变量,其格式应该是${variable name},就像${reportDirectory},但是您使用{folder}/{TestXml},它们的用途是什么,用作静态值还是变量

下面是我使用的个人资料

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-testng</artifactId>
            <version>2.19.1</version>
        </dependency>
    </dependencies>
    <configuration>
        <suiteXmlFiles>
            <suiteXmlFile>src/test/resources/testng/function-suite.xml</suiteXmlFile>
        </suiteXmlFiles>
    </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
2.19.1
org.apache.maven.surefire
surefire测试
2.19.1
src/test/resources/testng/function-suite.xml

我认为您的命令和pom.xml中存在一些问题

1) 配置文件名后面应该跟“-p”,我认为命令应该是mvn test-p BVT,而不是{testxml}

2) 在pom.xml中要使用变量,其格式应该是${variable name},就像${reportDirectory},但是您使用{folder}/{TestXml},它们的用途是什么,用作静态值还是变量

下面是我使用的个人资料

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-testng</artifactId>
            <version>2.19.1</version>
        </dependency>
    </dependencies>
    <configuration>
        <suiteXmlFiles>
            <suiteXmlFile>src/test/resources/testng/function-suite.xml</suiteXmlFile>
        </suiteXmlFiles>
    </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
2.19.1
org.apache.maven.surefire
surefire测试
2.19.1
src/test/resources/testng/function-suite.xml