1

I'm applying BDD methodology using Cucumber, which is GREAT!

The problem is that my test suite getting bigger and bigger and now I get the following exception which fails my test from the wrong reason...

I'm using all sort or Cucumber features, such as: Background, Scenario Outline and simple scenarios. I run the tests like this:

@RunWith(Cucumber.class)
@Cucumber.Options(features={"...../controller1"})
public class RunCukes1Test {
}

I split my feature files to different directories (controller1, controller2...) and runners (RunCukes1Test, RunCukes2Test...), but this didn't help.

When I run each test itself everything is ok, but when I run it all using mave lifecycle test, it fails. Does anyone know of any best practices in Java Cucumber to avoid problems of such.

    Tests run: 5896, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 33.082 sec
Running com.kenshoo.urlbuilder.appservice.controller.RunCukes4Test

Tests run: 11838, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 80.833 sec
Exception in thread "Thread-73" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2882)
    at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:515)
    at java.lang.StringBuffer.append(StringBuffer.java:306)
    at java.io.BufferedReader.readLine(BufferedReader.java:345)
    at java.io.BufferedReader.readLine(BufferedReader.java:362)
    at org.codehaus.plexus.util.cli.StreamPumper.run(StreamPumper.java:129)
Exception in thread "ThreadedStreamConsumer" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOfRange(Arrays.java:3209)
    at java.lang.String.<init>(String.java:215)
    at java.lang.StringBuffer.toString(StringBuffer.java:585)
    at org.apache.maven.surefire.report.PrettyPrintXMLWriter.escapeXml(PrettyPrintXMLWriter.java:167)
    at org.apache.maven.surefire.report.PrettyPrintXMLWriter.addAttribute(PrettyPrintXMLWriter.java:178)
    at org.apache.maven.surefire.shade.org.codehaus.plexus.util.xml.Xpp3DomWriter.write(Xpp3DomWriter.java:50)
    at org.apache.maven.surefire.shade.org.codehaus.plexus.util.xml.Xpp3DomWriter.write(Xpp3DomWriter.java:55)
    at org.apache.maven.surefire.shade.org.codehaus.plexus.util.xml.Xpp3DomWriter.write(Xpp3DomWriter.java:39)
    at org.apache.maven.surefire.report.XMLReporter.testSetCompleted(XMLReporter.java:128)
    at org.apache.maven.surefire.report.MulticastingReporter.testSetCompleted(MulticastingReporter.java:51)
    at org.apache.maven.surefire.report.TestSetRunListener.testSetCompleted(TestSetRunListener.java:115)
    at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:97)
    at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:67)
    at java.lang.Thread.run(Thread.java:662)

Results :

Tests run: 11790, Failures: 0, Errors: 0, Skipped: 0
Kowser
  • 8,123
  • 7
  • 40
  • 63
LiorK
  • 1,640
  • 1
  • 19
  • 23
  • So what happened with the other similar question: http://stackoverflow.com/questions/13381977/jenkins-build-fails-after-running-cucumber-tests-on-java-heap-space-exception? – maba Nov 14 '12 at 16:18
  • I think there are two different problems. One is during the cucumber (in dev env) and one is after the cucumber (in build env). – LiorK Nov 14 '12 at 16:24
  • But did you get help on the other question? Did that problem get solved? – maba Nov 14 '12 at 16:25
  • It is getting to a good direction. It seems that the -XX:MaxPermSize is a factor for during Cucumber running, and the -Xmx is a factor for the post Cucumber running, while parsing the results. – LiorK Nov 15 '12 at 15:01

1 Answers1

1

I got an answer to another java-heap-space exception I had, after the cucumber tests running. You can see it here - related problem

My theory is that the -XX:MaxPermSize is a factor for during Cucumber running, as Cucumber generates tests code and PermSize is related to amount of code as described what is permsize in java

The -Xmx is a factor for the post Cucumber running, while parsing the tests results.

So the solution is to find the balance between them both and the actual available memory.

Community
  • 1
  • 1
LiorK
  • 1,640
  • 1
  • 19
  • 23