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

时间:2015-05-28 11:54:43

标签: java unit-testing maven selenium junit

我已经使用Junit测试设置了一个maven项目,以便在我们的构建服务器上运行Selenium(java)脚本。从我读到的内容Maven意味着运行文件夹test.java

中指定的任何文件

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

然而,当我运行mvn test时,maven运行标题中任何位置都有关键字test的所有方法,即Test_A_1423,标题中包含“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>
`

1 个答案:

答案 0 :(得分:3)

你有正则表达式来包含/排除测试。 有关surefire插件的文档,请参阅here

相关问题