简体   繁体   中英

Memory issue while running tests through testng

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

Can someone plz help here

Thanks in advance

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

where,

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

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.

Thanks..there seems to an issue with testng as well. I upgraded to 7.0.0-beta version and it worked fine.

https://github.com/citrusframework/citrus/issues/337

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM