Issue migrating from junit to TestNG using Ant

47 views
Skip to first unread message

kdford

unread,
Aug 27, 2013, 4:58:13 PM8/27/13
to testng...@googlegroups.com
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">
    <classpath>
      <pathelement location="lib/testng-6.8.jar"/>
    </classpath>
  </taskdef>
  
  <!-- 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) -->
  <path id="classes">
    <pathelement location="build/classes" />
    <pathelement location="lib" />
    <pathelement location="." />
    <pathelement location="../dependentProject.war/WebContent/WEB-INF/classes" />
    <fileset dir="lib">
        <include name="**/*.jar" />
    </fileset>
  </path>
 
  <!-- 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"/> 
    </testng>
 
  </target>


With the following testng xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
  <test name="Test">
    <classes>
      <class name="com.mycomapny.test.FvtSuccess"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->


Gives the following results
> ant runTestNG 
Buildfile: build.xml
Trying to override old definition of task testng
runTestNG:
   [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.
BUILD SUCCESSFUL
Total time: 2 seconds


Neeraj Lad

unread,
Oct 30, 2014, 12:16:18 PM10/30/14
to testng...@googlegroups.com
Hi ,

Is there any solution for given error ?
I am also getting same error.

Please let me know if any solution u got 

Thanks
Neeraj
Reply all
Reply to author
Forward
0 new messages