gpt4 book ai didi

java - Maven 使用关键字 "Test"运行所有测试

转载 作者:行者123 更新时间:2023-11-29 05:05:34 27 4
gpt4 key购买 nike

我已经建立了一个带有 Junit 测试的 Maven 项目,以便在我们的构建服务器上运行 Selenium (java) 脚本。据我了解,Maven 旨在运行文件夹 test.java

中指定的任何文件

考虑到这一点,我使用 @RunWith@SuiteClasses 使用 TestAll 类设置我的项目,以专门运行我想要的类和测试。

但是,当我运行 mvn test 时,maven 会运行所有在标题中的任何位置具有关键字 test 的方法,即 Test_A_1423,所有在标题中带有“Test”的类中的测试以及任何带有关键字“Test”的包。如何只运行我想要的测试,或者我是否需要从我不想运行的任何类或方法中删除“测试”。包括我的 pom.xml 文件

`
<modelVersion>4.0.0</modelVersion>
<groupId>cyberx.automation</groupId>
<artifactId>tests</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>cyberx.test.automation</name>
<url>http://maven.apache.org</url>
<!--<repositories>-->
<!--<repository>-->
<!--<id>central</id>-->
<!--<name>bintray</name>-->
<!--<url>http://jcenter.bintray.com</url>-->
<!--</repository>-->
<!--</repositories>-->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.testng</groupId>-->
<!--<artifactId>testng</artifactId>-->
<!--<version>6.9.4</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
`

最佳答案

您有正则表达式来包含/排除测试。参见 here获取 surefire 插件的文档。

关于java - Maven 使用关键字 "Test"运行所有测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30505906/

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