【问题标题】:Maven not Running Tests Specified in ProfileMaven 未运行配置文件中指定的测试
【发布时间】:2012-04-24 12:46:51
【问题描述】:

我的 maven pom 文件中有一个不同的简单配置文件,用于在正常测试阶段运行一些集成测试。请注意,我不想在正常的集成测试阶段运行这些测试,因为我不想构建战争和部署等。测试可以像正常的 JUnit 测试一样运行。

这是我的个人资料:

<profile>
  <id>AdminSeltests</id>
  <build>
    <plugins>
   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.12</version>

      <configuration>
          <includes>
            <include>**/*/TestSellerSignupWizard.java</include>
          </includes>
      </configuration>

      <executions>
      <execution>
        <id>execution2</id>
        <phase>test</phase>
       </execution>
      </executions>
    </plugin> 
    </plugins>
  </build>
</profile>

我的测试被称为:

com.xxxxx.xxx.client.selenium.seller_signup.TestCustomerSignupWizard

但是,当我运行上述配置文件时:

mvn test -P AdminSeltests

没有运行测试。我尝试了以下作为值:

<include>**/TestSellerSignupWizard.*</include>
<include>**/TestSeller*.*</include>
<include>**/TestSeller*.java</include>
<include>**/*/TestSeller*.java</include>
<include>
  com.xxxxx.xxx.client.selenium.seller_signup.TestCustomerSignupWizard.java
</include>

这些都不起作用。

有什么想法吗?

谢谢 亚当

已解决: 我正在使用maven-surefire-plugin,它有一个自动的includes 部分,其中包括您的正常测试内容。所以我做了一个exclude 配置来排除正常的单元测试,然后是一个include 部分来包含我想要运行的集成测试模式

不知道为什么会这样,但确实如此:

<configuration>
    <excludes>
      <exclude>**/Test*.java</exclude>
      <exclude>**/*Test.java</exclude>
      <exclude>**/*TestCase.java</exclude>
    </excludes>
    <includes>
      <include>**/ITTestSellerSignupWizard.java</include>
    </includes>
</configuration>

感谢大家的帮助。

【问题讨论】:

    标签: testing maven selenium profile


    【解决方案1】:

    您粘贴的实际代码显然不起作用,因为您在TestCustomerSignupWizard 中进行测试时提到了TestSellerSignupWizard 类。但我认为这是一个错字,实际上并不重要,因为 Surefire 包含的默认掩码之一是 **/Test*.java,在这种情况下非常适合您。

    所以这一切看起来都是可行的解决方案,所以恐怕问题是你的测试类路径中没有这个类。你提到这在某种程度上与集成测试有关,所以这个类可能位于src/it/java,而不是src/test/java,这是 Maven 对 Surefire 的默认设置。如果我是对的,您应该将此类移至 src/test/java 或使用(如您尝试的那样)替代 Surefire 执行,但覆盖 testSourceDirectory 参数(link)。

    【讨论】:

    • 你是对的错字。测试在 target\test-classes\com***\admin\client\selenium\seller_signup\TestSellerSignupWizard.class 所以应该在类路径上。如果我运行“mvn test”一切正常。 :-(
    • 尝试将&lt;configuration&gt;移动到&lt;execution&gt;
    猜你喜欢
    • 2012-09-16
    • 2018-04-20
    • 2016-12-13
    • 2018-03-07
    • 2013-07-13
    • 1970-01-01
    • 2015-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多