Hi All....
I created a
test case using
TestNG and am trying to run it using
Ant.
I am using TestNG version 5.8 and
java 1.4.
I put my test-case in a package called tests. And made a jar out of it. The jar is put in the classpath.
Now when I run the case, I get the error:
[testng] [ClassHelper] Could not instantiate.
My testng.xml is below:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Demo TestNG" parallel="methods" thread-count="7" >
<test name="Demo TestNG">
<classes>
<class name="tests.TestDemo">
<methods>
<include name="firstTest" />
</methods>
</class>
</classes>
</test>
</suite>
I also tried changing the testng.xml to work for packages as below:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Demo TestNG" parallel="methods" thread-count="7" verbose="3" >
<test name="Demo TestNG">
<packages>
<package name="tests" />
</packages>
</test>
</suite>
My test case is below:
package tests;
public class TestDemo
{
/*
* @testng.test
*/
public void firstTest() {
System.out.println("Hello");
}
}
Below is my Ant build.xml
<project name="Demo TestNG" basedir="." default="run-tests">
<property name="classes.dir" value="../classes" />
<property name="test.src.dir" value="../src"/>
<path id="testngLoc">
<fileset dir="../lib" includes="lib/testng.jar"/>
</path>
<path id ="testCaseLoc">
<fileset dir="../lib" includes="lib/testCases.jar"/>
</path>
<taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="testngLoc"/>
<target name="run-tests">
<echo message="running tests"/>
<testng classpathref="testngLoc" outputDir="." sourcedir="${test.src.dir}" verbose="2">
<classpath>
<pathelement path="${testCaseLoc}"/>
</classpath>
<xmlfileset dir="." includes="testng.xml" />
</testng>
</target>
</project>
Below is the stacktrace of the error:
Could someone tell what I am missing??