You can easily convert your JUnit tests with org.testng.JUnitConverter, which you can invoke as follows:
Here is a sample use that will convert all the JUnit tests in the src/ directory to TestNG:
java org.testng.JUnitConverter -overwrite -annotation -srcdir srcNotes:
- JUnitConverter uses classes from tools.jar, which is located in $JAVA_HOME/lib/tools.jar, so make sure you have this jar file in your classpath.
- JUnitConverter only runs with the JDK5, so if you receive an error (such as "unknown -quiet parameter"), make sure your classpath only contains JDK5 jar files.
JUnitConverter also has an ant task, which you can invoke as follows:
<project name="test" default="init"> <target name="init"> <taskdef resource="testngtasks" /> </target> <target name="junitconvert" depends="init"> <junit-converter sourcedir="C:\dev\projects\test\java" outputdir="C:\dev\projects\temp" annotations="false" /> </target> </project>