【发布时间】:2015-05-28 11:54:42
【问题描述】:
我已经建立了一个带有 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>
`
【问题讨论】:
-
您可以使用 -Dtest=
指定要运行的测试
标签: java unit-testing maven selenium junit