2017-09-25 54 views
1

我有一个问题让我的测试使用maven命令运行。我到处搜索,但没有任何解决方案似乎解决了我的问题。我已经创建了一个我希望执行的测试的xml文件,并且我可以在testNG中运行它。我在项目的POM中创建了一个配置文件,但似乎没有实际运行测试,只是构建并结束。要运行的测试是Selenium测试。maven配置文件没有执行测试

,我使用的命令是“MVN验证-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> 

回答

0

我觉得有一些问题,在您的指挥的pom.xml 。

1) '-P' 应遵循的个人资料名称,我认为命令应该是MVN测试-P BVT,不{testxml}

2)中的pom.xml使用变量,它的格式应是$ {variable name},就像$ {reportDirectory}一样,但是您使用{folder}/{TestXml},您的目的是什么,用作静态值还是变量?

下面snnipet是档案I使用

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