testing - Maven 不运行配置文件中指定的测试

标签 testing maven selenium profile

我的 maven pom 文件中有一个 vary simple 配置文件,用于在正常测试阶段运行一些集成测试。请注意,我不想在正常的集成测试阶段运行这些测试,因为我不想构建 war 和部署等。测试像正常的 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>

谢谢大家的帮助。

最佳答案

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

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

关于testing - Maven 不运行配置文件中指定的测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10298115/

相关文章:

html - 如何访问Primeng表的style属性

java - 如何在 Eclipse 中将 GitHub 托管项目导入为 Java 项目?

java - 3rd party jar 的 Maven 导出不会通过 mvn install 导出

java - 无法使用 headless (headless)模式 Selenium 定位元素

python - Selenium 测试 - 无论如何都会打印所有内容

testing - 使用 Cypress ,如何测试不存在的元素?

testing - 我们如何测试 Roku 应用程序

maven - Docker-compose-使用Maven进行构建以重新使用Maven存储库

css - WebDriver - ":nth-of-type()"选择器是否适用于 IE 9?

java - 如何使用 Java 计算 Selenium WebDriver 中的 HTML 子标签