gpt4 book ai didi

java - Maven 配置文件不执行测试

转载 作者:太空宇宙 更新时间:2023-11-04 11:06:39 24 4
gpt4 key购买 nike

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

我使用的命令是“mvn verify -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>

最佳答案

我认为您的命令和 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>

关于java - Maven 配置文件不执行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46415045/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com