Robot Framework Maven Plugin and OutOfMemoryError: Java heap space

I’m using and I have this OutOfMemoryError which occurs when generating log.html file from the output.xml file.

Apparently this is a known issue, but it has not yet been solved (as to my version 2.8.1 of the robot framework). This exception usually occurs on Jenkins where all our tests are executed.
The only workaround I was able to put in place is the use of to generate the logs.
This means that logs generation will not be performed by robotframework:run goal but by another goal we define in the pom. This would cause a problem because I still want to be able to run, on my machine a small subset of tests by invoking

  mvn  robotframework:run -Dinclude=sniff 

without executing all the maven phases. when running the small subset of tests, logs should be generated by robot directly (as the default behavior).
When running

  mvn verify  

on jenkins, logs should be generated as a separated step, by the rebot tool.

Here’s how I did this.
I create a profile called useRebotForLogs where we set the property to NONE and where we execute rebot in post-integration-test:

 
<!-- This profile is activated by the option -DuseRebotForLogs -->
<profile>
   <id> use-rebot</id>
   <properties>
	<robot.log.file> NONE </robot.log.file>
   </properties>
   <activation>
	<property>
		<name>useRebotForLogs</name>
	</property>
   </activation>
   <build>
	<plugins>
             <plugin>
		<artifactId>maven-antrun-plugin</artifactId>
		<version>1.4</version>
		<executions>
			<execution>
				<id>generate-robot-logs</id>
				<phase>post-integration-test</phase>
				<configuration>
				<tasks>
                                   <echo message="${robot.report.folder}# python -m rebot output.xml" />
				   <exec executable="python" dir="${robot.report.folder}">
					<arg value="-m"/>
					<arg value="robot.rebot"/>
					<arg value="output.xml" />
				</exec>
				   <echo message="Robot logs were generated in ${robot.report.folder} " />				
				</tasks>
      			        </configuration>
				<goals>
					<goal>run</goal>
				</goals>
			</execution>
		</executions>
	</plugin>
</plugins>
</build>
</profile>

 

Another profile where we set the property robot.log.file to log.html:

 
<!-- This profile is activated by the option -DuseRebotForLogs is not present-->
<profile>
			<id> generate-logs</id>
			<properties>
				<robot.log.file> ${project.build.directory}/robotframework-reports/log.html </robot.log.file>
			</properties>
			<activation>
				<property>
					<name>!useRebotForLogs</name>
				</property>
			</activation>
		</profile>

Now, in the robotframework plugin configuration, we only specify the log file:

 

<plugin>
  <groupId>org.robotframework</groupId>
  <artifactId>robotframework-maven-plugin</artifactId>
  <version>1.4</version>
  .......
<configuration>
  <testCasesDirectory> src/test/resources/robotframework/tests</testCasesDirectory>
  <log>${robot.log.file}</log>
</configuration>
</plugin>							

This is it.
Now, if run

  mvn verify -DuseRebotForLogs 

logs will be generated using rebot and we will not have OutOfMemory exception anymore.

Advertisements
This entry was posted in maven, robot framework, testing. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s