通过Testng运行测试时出现内存问题 [英] Memory issue while running tests through testng

查看:81
本文介绍了通过Testng运行测试时出现内存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用testng版本6.9.10.我们已经使用硒3.5.3开发了将近2000个测试,并且正在并行运行10个线程.

I am using testng version 6.9.10. We have close to 2000 tests developed using selenium 3.5.3 and are running 10 threads in parallel.

我在执行时遇到以下错误:

Am getting the below error on execution:

[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,您可以提供以下参数:

This is common issue when you are executing large number of test case. The problem happens when TestNG tries to write report at the end, it goes out of memory and you loss all test results. One of the possible solution is increasing memory depending on system configuration, for example, with 3GB RAM you can provide below parameters:

-Xmx1250m -XX:MaxPermSize=128m -Xms256m

在哪里

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

另一种替代方法是关闭默认报告器,并使用自定义报告,如 TestNG ,并且遇到了相同的问题运行回归套件5年前发行.QAF提供了实时报告功能,即使在内存不足的情况下我们也没有看到在回归套件中执行大量(3000+)测试用例.附加功能是,我们不需要等待整个套件完成,并且可以在执行完测试用例后立即查看详细的报告.

Another alternate is turn off default reporters and use custom reporting like in json reporting in qaf. We are using TestNG with QAF framework and we encountered the same issue 5 years back while running the regression suite. QAF provided live reporting feature where we didn't seen out of memory issue even executing large number (3000+) of testcase in regression suite. Additional feature is, we don't need to wait for entire suite to complete and we can see detailed report of test case immediately after it get executed.

这篇关于通过Testng运行测试时出现内存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆