You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-users@maven.apache.org by Christoph Höger <ch...@cs.tu-berlin.de> on 2009/03/23 15:01:59 UTC

forking single tests from junit test suite

Hi,

I need to test a feature for my project on large test input files.
To get that, I create TestCases from a single TestSuite dynamically. The
relevant part of the pom looks like:


> 			<plugin>
> 				<groupId>org.apache.maven.plugins</groupId>
> 				<artifactId>maven-surefire-plugin</artifactId>
> 				<configuration>
> 					<reportFormat>plain</reportFormat>
> 					<trimStackTrace>false</trimStackTrace>
> 					<forkMode>perTest</forkMode>
> 					<argLine>-XX:+HeapDumpOnOutOfMemoryError</argLine>
> 					<excludes>
> 						<exclude>**/IncrementalParsePhase1Test.java</exclude>
> 						<exclude>**/incremental/testparser/*.java</exclude>
> 					</excludes>
> 					<includes>
> 						<include>**/IncrementalParsingTestSuite.java</include>
> 					</includes>
> 				</configuration>
> 			</plugin>

In my TestSuite there runs a loop:


> for (int i = 0; i < Lexer.getCachedInput().size(); i++) {
> 				//brake for large test cases
> 				if (i % (1 + (Lexer.getCachedInput().size() / 20)) != 0)
> 					continue;
> 
> 				Range diffRange = new Range(i, i);
> 
> 				IncrementalParsePhase1Test test = new IncrementalParsePhase1Test(
> 						Lexer.getInputFileName(), Lexer.getCachedInput(),
> 						generatedStates, diffRange, rootAbsy, Lexer.getCachedInput().get(i).getSavedConfiguration());
> 				suite.addTest(test);
> 			}

The problem is, that maven does not seem to run every testCase in a new
vm, but reuses the old one (and somehow prevents the GC from cleaning
up old testcases), so earlier or later I run into a heap overflow.

This is especially bad, as I want to measure the performance of some operations and the GC seems to interrupt my threads thus creating huge performance problems.

So is it possible to make surefire run each test in a single vm?

regards

Christoph