Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

One problem seen with test suites with a large number of tests, or a significant amount of code tested in the testing itself is the JVM running out of Heap space. One way to fix this is to increase the Heap size available to testng:

<testng outputdir="${basedir}/test-report">
  <jvmarg value="-Xmx512m" />
  <!-- rest of xml -->

But this is not always the best solution as the total number of tests may grow to an indeterminate amount, thus requiring more and more heap.

The better solution then is to invoke the testng suites in separate JVMs where you can determine the number of Classes run per suite by defining them in the xml.

To accomplish this, a bash script must be created, and a change to build.xml.

Put this bash script in the root directory of your project:



fileArray=($(find src/ -iname "*Test.xml"))



for (( i=0; i<${tLen}; i++ ));
        #Get just the basename of the file since the default build.xml copies it to the test directory
        FILE=$(basename ${fileArray[$i]})
        echo "Kicking off the ant testing for $FILE"
        #Kick off the ant and pass in the file name, this requires changes to the default build.xml
        ant -Dtest.file="$FILE" test
        echo "finished processing file"

The last piece to the puzzle is to change the build.xml to take in the test.file param line as the test xml file:

<target name="test" depends="buildtest" description="Run the tests">            
  <taskdef resource="testngtasks" classpath="${testng.jar}" />
  <path id="test.path">
    <path path="${test.dir}" />
    <fileset dir="${lib.dir}/test">
      <include name="*.jar"/>
    <path path="${bootstrap.dir}" />
    <path refid="build.classpath" />
  <testng outputdir="${basedir}/test-report">
    <!-- java 6 requires this -->
    <jvmarg line="-Dsun.lang.ClassLoader.allowArraySyntax=true"/>
    <classpath refid="test.path" />
    <!--<xmlfileset dir="${test.dir}" includes="*Test.xml" />-->
    <xmlfileset dir="${test.dir}" includes="${test.file}" />

The only change here was to remove the *Test.xml and substitute it for a ${test.file} which the test.file is passed in via the command line in the bash script ant -Dtest.file="$FILE" test