我使用的是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
有人可以帮助这里
提前致谢
当您执行大量测试用例时,这是常见问题。问题发生在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+)测试用例,我们也没有看到内存不足问题。附加功能是,我们不需要等待整个套件完成,我们可以在执行后立即看到测试用例的详细报告。
谢谢..这似乎也与testng有关。我升级到7.0.0-beta版本,它工作正常。