surefire-plugin不遵守threadCount参数

泰蒂安

几天以来,我试图查看在并行运行Selenium测试时配置中的错误所在。

我有一个带有2个节点的Selenium Grid。在我的pom.xml中,我将surefire设置为以特定类别而不是其他测试的方式逐个运行测试方法。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <executions>
                <execution>
                    <id>default-test</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <parallel>methods</parallel>
                        <perCoreThreadCount>false</perCoreThreadCount>

                        <threadCount>2</threadCount>
                        <reuseForks>false</reuseForks>
                        <groups>
                            com.something.categories.Safe,
                            com.something.categories.Parallel
                        </groups>
                    </configuration>
                </execution>
                <execution>
                    <id>no-safe</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <excludedGroups>
                            com.something.categories.Safe,
                            com.something.Parallel
                        </excludedGroups>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

当我启动测试mvn clean test -Dtest ='TestAwesome'时,包含在TestAwesome中所有测试是同时启动的(我看到打开了两个以上的浏览器),因此不尊重我的threadCount值。

我想念什么吗?

答案后的版本这里是我的部分pom.xml,用于解决我的问题

<profiles>
    <profile>
        <id>selenium-tests</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.18.1</version>
                    <configuration>
                        <parallel>all</parallel>
                        <threadCount>${threads}</threadCount>
                        <perCoreThreadCount>false</perCoreThreadCount>
                        <useUnlimitedThreads>true</useUnlimitedThreads>
                        <systemProperties>
                            <browser>${browser}</browser>
                            <screenshotDirectory>${project.build.directory}/screenshots</screenshotDirectory>
                            <gridURL>${seleniumGridURL}</gridURL>
                            <env>${env}</env>
                        </systemProperties>
                        <groups>${groups}</groups>
                        <excludedGroups>${excludedGroups}</excludedGroups>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
卡斯滕

由于您使用的是surefire的足够现代的版本,因此您可能想要结合使用useUnlimitedThreads = true尝试使用threadCountMethods参数而不是threadCount ,即使它看起来是违反直觉的。

surefire jUnit示例

从Surefire 2.7开始,无需使用任何其他依赖项即可使用整套并行选项。从Surefire 2.16开始,引入了新的线程计数属性,即threadCountSuites,threadCountClasses和threadCountMethods

叉选项和并行执行

例如,线程数量不受限制,最多有三个并发线程来执行套件:parallel = all,useUnlimitedThreads = true,threadCountSuites = 3。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

surefire并行threadCount被忽略(JUnit 4)

来自分类Dev

Eclipse中缺少maven-surefire-plugin

来自分类Dev

难以理解Maven Surefire插件的并行参数

来自分类Dev

如何获取生成的maven-surefire-report-plugin的图标

来自分类Dev

Maven tycho-surefire-plugin失败,返回码13

来自分类Dev

maven-surefire-report-plugin不接受其配置

来自分类Dev

如何获取生成的maven-surefire-report-plugin的图标

来自分类Dev

使用 maven-surefire-plugin 管理 Maven 插件的奇怪行为

来自分类Dev

Surefire Maven插件不执行测试之一

来自分类Dev

maven-surefire-plugin,jacoco-maven-plugin显示没有覆盖

来自分类Dev

使用maven-surefire-plugin或maven-failsafe-plugin运行硒测试?

来自分类Dev

无法从命令行覆盖pom maven-surefire-plugin

来自分类Dev

Maven-surefire-plugin在SpringBoot 2.2.2.RELEASE及更高版本中不起作用

来自分类Dev

是否可以指定其他JVM以使用tycho-surefire-plugin运行Eclipse

来自分类Dev

无法执行目标org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test

来自分类Dev

maven-surefire-plugin 运行单一方法,但在课堂上失败

来自分类Dev

缺少 Maven Surefire 插件?

来自分类Dev

如何使maven-surefire-plugin重用创建的线程来执行所有Maven模块中的所有测试

来自分类Dev

为什么Maven surefire-report-plugin创建错误消息“此平台不支持字符编码$ {outputEncoding}”?

来自分类Dev

为什么maven-surefire-plugin跳过带有日志消息“因为已针对该配置运行”的测试?

来自分类Dev

为什么在 Maven 项目中使用 JUnit 5 时必须强制使用 maven-surefire-plugin?

来自分类Dev

Maven Surefire surefire.forkNumber 的 Gradle 等价物

来自分类Dev

Maven Surefire插件+并行构建

来自分类Dev

Maven Surefire Junit测试套件

来自分类Dev

Maven Surefire Permgen空间不足

来自分类Dev

Maven Surefire插件+并行构建

来自分类Dev

Maven Surefire找不到测试

来自分类Dev

KeePass kdbx不遵守-pw参数

来自分类Dev

Google日历Feed链接不遵守参数

Related 相关文章

  1. 1

    surefire并行threadCount被忽略(JUnit 4)

  2. 2

    Eclipse中缺少maven-surefire-plugin

  3. 3

    难以理解Maven Surefire插件的并行参数

  4. 4

    如何获取生成的maven-surefire-report-plugin的图标

  5. 5

    Maven tycho-surefire-plugin失败,返回码13

  6. 6

    maven-surefire-report-plugin不接受其配置

  7. 7

    如何获取生成的maven-surefire-report-plugin的图标

  8. 8

    使用 maven-surefire-plugin 管理 Maven 插件的奇怪行为

  9. 9

    Surefire Maven插件不执行测试之一

  10. 10

    maven-surefire-plugin,jacoco-maven-plugin显示没有覆盖

  11. 11

    使用maven-surefire-plugin或maven-failsafe-plugin运行硒测试?

  12. 12

    无法从命令行覆盖pom maven-surefire-plugin

  13. 13

    Maven-surefire-plugin在SpringBoot 2.2.2.RELEASE及更高版本中不起作用

  14. 14

    是否可以指定其他JVM以使用tycho-surefire-plugin运行Eclipse

  15. 15

    无法执行目标org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test

  16. 16

    maven-surefire-plugin 运行单一方法,但在课堂上失败

  17. 17

    缺少 Maven Surefire 插件?

  18. 18

    如何使maven-surefire-plugin重用创建的线程来执行所有Maven模块中的所有测试

  19. 19

    为什么Maven surefire-report-plugin创建错误消息“此平台不支持字符编码$ {outputEncoding}”?

  20. 20

    为什么maven-surefire-plugin跳过带有日志消息“因为已针对该配置运行”的测试?

  21. 21

    为什么在 Maven 项目中使用 JUnit 5 时必须强制使用 maven-surefire-plugin?

  22. 22

    Maven Surefire surefire.forkNumber 的 Gradle 等价物

  23. 23

    Maven Surefire插件+并行构建

  24. 24

    Maven Surefire Junit测试套件

  25. 25

    Maven Surefire Permgen空间不足

  26. 26

    Maven Surefire插件+并行构建

  27. 27

    Maven Surefire找不到测试

  28. 28

    KeePass kdbx不遵守-pw参数

  29. 29

    Google日历Feed链接不遵守参数

热门标签

归档