我正在使用testng版本6.9.10。我们已经使用硒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
有人可以在这里帮忙吗
预先感谢
答案 0 :(得分:1)
在执行大量测试用例时,这是常见问题。当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+)测试用例,我们也看不到内存不足的问题。附加功能是,我们不需要等待整个套件完成,并且可以在执行完测试用例后立即查看详细的报告。
答案 1 :(得分:0)
谢谢..testng似乎也有问题。我升级到7.0.0-beta版本,并且运行良好。