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

Maven runs all tests with keyword "Test"

我已经在我们的构建服务器上设置了一个带有 Junit 测试的 Maven 项目,以测试 运行 Selenium (java) 脚本。根据我的阅读,Maven 意味着 运行 文件夹 test.java

中指定的任何文件

考虑到这一点,我使用 @RunWith@SuiteClasses 到 运行 使用 TestAll class 设置我的项目,特别是 classes 和测试我想了。

但是,当我 运行 mvn test maven 运行s 标题中任何地方都有关键字测试的所有方法时,即 Test_A_1423,所有测试都在 class 标题中带有 "Test",任何包中的所有内容都带有关键字 "Test"。如何仅 运行 我想要的测试或我是否需要从任何 class 或我不想 运行 的方法中删除 "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>
`

您有 include/exclude 测试的正则表达式。 有关 surefire 插件的文档,请参阅 here