Maven 2, TestNG and Surefire-plugin

Since I have decided to use this blog as a easy access to find things that I don’t want to search all over, here is the way I configure my maven-2 projects with TestNG. Here is the relevant pom entry in <build><plugins>

    <argLine>-Xms128m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=256m</argLine>

You must make sure that the plugin snapshot repository is configured in your pom.xml, otherwise the 2.4-SNAPSHOT jar will not be found. To do that make sure the following element is defined in the <pluginRepositories> element:


Note, I put all my TestNG configuration information in testng.xml. Without this file you would get all kinds of strange errors, when the surefire plugin triggers the test goal. Below is a sample testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "">

<suite name="Sample_TestNG_Suite" verbose="4">
  <test name="DefaultTestPackage">
      <package name="org.anonymous.package"/>

You also need to make sure the testNG <dependency> element is available in the pom, lit below


Remember 5.6 is not yet available in central repositories, to install it locally use the following standard maven-2 install goal (NOTE: the whole command below is a single line)

$ mvn install:install-file -Dfile=testng-5.6-jdk15.jar -DgroupId=org.testng -DartifactId=testng -Dversion=5.6 -Dpackaging=jar \ -Dclassifier=jdk15 -DgeneratePom=true

That’s it, you should be good to go, just annotate (I use JDK5) your test POJO’s and surefire plugin will be triggered by the default maven2 lifecycle.



  1. Alex said

    Got everything done as you said. Maven reports the following:
    (have to type it manually cause its impossimble to copy from windows cmd shell) :
    org.xml.sax.SAXParseException: The proccessing instruction target matching “[xX][mM][lL]” is not allowed.
    and lower:
    [ERROR]: No test suite found. Nothing to run

    If you are some kind of an expert in this field, wuold you please tell me what should be done, maybe a hint.))

  2. Alex said

    Thanks, I ‘ve already found my answer at The reason was that I had gapes befor
    tag in testng.xml file.

RSS feed for comments on this post · TrackBack URI

Comments are closed.

%d bloggers like this: