My TestNG tests run in Eclipse but I am seeing errors when I try to run them by ant (1.7.1), using Java 6.
Below is part of my build.xml
<!-- Define <testng> task -->
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<pathelement location="lib/testng-6.8.jar"/>
<!-- Directory name where the TestNG report will be saved. -->
<property name="testng.output.dir" value="testng_output"/>
<!-- Directory path of compiled classes(i.e *.class) -->
<pathelement location="build/classes" />
<pathelement location="lib" />
<pathelement location="." />
<pathelement location="../dependentProject.war/WebContent/WEB-INF/classes" />
<include name="**/*.jar" />
<!-- Target to run TestNG. It will run according to what are defined in testng.xml.
The report will be saved at .../testng_output/index.html.-->
<target name="runTestNG">
<mkdir dir="${testng.output.dir}"/><!-- Create the output directory. -->
<testng outputdir="${testng.output.dir}" classpathref="classes" verbose="2">
<xmlfileset dir="." includes="testng.xml"/>
With the following testng xml file
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="none">
<class name="com.mycomapny.test.FvtSuccess"/>
Gives the following results
Trying to override old definition of task testng
[testng] Exception in thread "main" java.util.ServiceConfigurationError: org.testng.ITestNGListener: Provider test.serviceloader.TmpSuiteListener not found
[testng] at java.util.ServiceLoader$ServiceIterator.next(ServiceLoader.java:208)
[testng] at org.testng.TestNG.addServiceLoaderListeners(TestNG.java:956)
[testng] at org.testng.TestNG.initializeConfiguration(TestNG.java:891)
[testng] at org.testng.TestNG.run(TestNG.java:1005)
[testng] at org.testng.TestNG.privateMain(TestNG.java:1338)
[testng] at org.testng.TestNG.main(TestNG.java:1307)
[testng] The tests failed.