Selenium Webdriver+testNG+ANT
I have an error running -ant runtest
C:\seleniumtests>ant runtest
Buildfile: C:\seleniumtests\build.xml
compileTests:
[jar] Building jar: C:\seleniumtests\AntruTests.jar
runtest:
[taskdef] Could not load definitions from resource testngtasks. It could not b
e found.
BUILD FAILED
C:\seleniumtests\build.xml:38: Problem: failed to create task or type testng
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.
Total time: 1 second
build.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="AntruTests">
<!-- Properties storage -->
<property file="build.properties"/>
<!-- Project's folders locations -->
<property name="project.path" value="." />
<!-- Set class path libraries to be used for compilation -->
<path id="class.path">
<pathelement location="lib" path="lib/selenium-java-2.37.0.jar"/>
<pathelement location="lib" path="lib/selenium-server-standalone-2.37.0.jar"/>
</path>
<!-- Title for ReportNG -->
<property name="report.title" value="Automated tests report for AntruTests"/>
<!-- Compile classes -->
<target name="compileTests">
<javac classpathref="class.path" includeantruntime="false" destdir="C:\seleniumtests" encoding="UTF-8" optimize="off"
debug="on" failonerror="true" srcdir="C:\seleniumtests" />
<jar destfile="AntruTests.jar" basedir="C:\seleniumtests" />
</target>
<target name="prepareForRunning" depends="compileTests">
<delete dir="${tests.results.folder}" />
<mkdir dir="${tests.results.folder}" />
</target>
<target name="runtest" depends="compileTests" description="Runtests">
<taskdef resource="testngtasks" classpath="${lib.dir}/testng-6.8.7.jar"/>
<testng outputdir="${testng.output.dir}" classpathref="classes">
<xmlfileset dir="${lib.dir}" includes="testng.xml"/>
</testng>
</target>
</project>
What I am doing wrong?
Thanks!
Best Answer
Ant processes [taskdef] before setting ${lib.dir}. You need to set absolute path like,