gpt4 book ai didi

java - 通过 testng 运行测试时出现内存问题

转载 作者:行者123 更新时间:2023-12-02 10:48:36 33 4
gpt4 key购买 nike

我使用的是 testng 版本 6.9.10。我们使用 selenium 3.5.3 开发了近 2000 个测试,并并行运行 10 个线程。

执行时出现以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project config: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: There was an error in the forked process
[ERROR] java.lang.OutOfMemoryError: Java heap space
[ERROR] at java.util.Arrays.copyOf(Arrays.java:3332)
[ERROR] at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
[ERROR] at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
[ERROR] at java.lang.StringBuffer.append(StringBuffer.java:270)
[ERROR] at java.io.StringWriter.write(StringWriter.java:101)
[ERROR] at freemarker.core.DollarVariable.accept(DollarVariable.java:41)
[ERROR] at freemarker.core.Environment.visit(Environment.java:324)
[ERROR] at freemarker.core.MixedContent.accept(MixedContent.java:54)
[ERROR] at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
[ERROR] at freemarker.core.IteratorBlock$IterationContext.executeNestedBlockInner(IteratorBlock.java:268)
[ERROR] at freemarker.core.IteratorBlock$IterationContext.executeNestedBlock(IteratorBlock.java:220)
[ERROR] at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:194)
[ERROR] at freemarker.core.Environment.visitIteratorBlock(Environment.java:572)
[ERROR] at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:78)
[ERROR] at freemarker.core.IteratorBlock.accept(IteratorBlock.java:64)
[ERROR] at freemarker.core.Environment.visit(Environment.java:324)
[ERROR] at freemarker.core.MixedContent.accept(MixedContent.java:54)
[ERROR] at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
[ERROR] at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:48)
[ERROR] at freemarker.core.Environment.visit(Environment.java:324)
[ERROR] at freemarker.core.MixedContent.accept(MixedContent.java:54)
[ERROR] at freemarker.core.Environment.visit(Environment.java:324)
[ERROR] at freemarker.core.Environment.include(Environment.java:2072)
[ERROR] at freemarker.core.Include.accept(Include.java:167)
[ERROR] at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
[ERROR] at freemarker.core.IfBlock.accept(IfBlock.java:48)
[ERROR] at freemarker.core.Environment.visit(Environment.java:324)
[ERROR] at freemarker.core.MixedContent.accept(MixedContent.java:54)
[ERROR] at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
[ERROR] at freemarker.core.IteratorBlock$IterationContext.executeNestedBlockInner(IteratorBlock.java:268)
[ERROR] at freemarker.core.IteratorBlock$IterationContext.executeNestedBlock(IteratorBlock.java:220)
[ERROR] at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:194)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

有人可以帮忙吗

提前致谢

最佳答案

这是执行大量测试用例时的常见问题。当 TestNG 尝试在最后写入报告时,就会出现问题,内存不足,您会丢失所有测试结果。可能的解决方案之一是根据系统配置增加内存,例如,对于 3GB RAM,您可以提供以下参数:

-Xmx1250m -XX:MaxPermSize=128m -Xms256m

哪里,

-Xms<size>        set initial Java heap size
-Xmx<size> set maximum Java heap size

另一个替代方案是关闭默认报告器并使用自定义报告,如json reporting in qaf 。我们正在使用TestNG with QAF framework五年前,我们在运行回归套件时遇到了同样的问题。提供 QAF live reporting即使在回归套件中执行大量(3000+)测试用例,我们也没有看到内存不足问题。附加功能是,我们不需要等待整个套件完成,我们可以在测试用例执行后立即看到详细的报告。

关于java - 通过 testng 运行测试时出现内存问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52361177/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com