build.xml problem

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

build.xml problem

Ajith
Selenium - ANT -TestNG

I have written a build.xml, where it produces a error stating " classname attribute of taskdef element is undefined "

Here is my build.xml

<?xml version="1.0" encoding="UTF-8"?>

<project name ="AutomationScripts" default="test" basedir=".">



<echo message ="Testing selenium server... Plz wait"/>


<target name="startServer">

<echo message ="Start selenium server... Plz wait"/> 

<java jar="..\lib\selenium-server-standalone-2.19.0.jar"

fork="true">

<jvmarg value="-Dhttp.proxyHost=192.168.0.200"/>

<jvmarg value="-Dhttp.proxyPort=3128"/> </java>

<echo message ="Started selenium server"/>

</target>

<target name="test" depends="startServer">

<echo message="Test run. Please wait"/>

<mkdir dir="out" />

<java classname="RosettastoneMain" classpath="..\AutomationScripts\bin"

dir="C:\Program Files\Java\jdk1.6.0_11\bin">

<classpath>

<fileset dir="..\AutomationScripts\lib" includes="*.*"/>
</classpatha></java>
<taskdef name="testng" classpath="org.testng.TestNG">     ---------> It produces error in this stmt
<classpath>
<pathelement location="../lib/testng-6.2.jar"/>
</classpath>
</taskdef>
<property name="testng.output.dir" value="testngOutput"/>


<path id="classes">
<fileset dir="../lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${bin.dir}"/>
</path>
<mkdir dir="${testng.output.dir}"/>
<testng outputdir="${testng.output.dir}" classpathref="classes"> 
<xmlfileset dir="." includes="testng.xml"/> 
</testng>
</target>

<target name="stopServer">
<echo message="stop selenium server. Plz wait"/>
<get taskname="selenium-shutdown"
src="http://localhost:4444/selenium-server-standalone-2.0rc2/driver/?cmd=shutDown"
dest="./out/sever.stop.status.txt" ignoreerrors="true"/>
</target>
</project>

Can any one help me out
Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: build.xml problem

softwaretestingforum
Administrator
I doubt about the class path and so build not being able to recognize the testng jar file.
More over this statement looks wrong -

Ajith wrote
</classpatha></java>
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: build.xml problem

Ajith
Yes , its an typo error

it looks </classpath></java> in my file

what should we do in order to recognize the testng jar
I have added to reference libraries - through configure build path
also added up in lib folder
but still produces the same error

Thanks

Reply | Threaded
Open this post in threaded view
|

Re: build.xml problem

softwaretestingforum
Administrator
I can not really figure out, till I see project structure.
Let me share my project structure and build file where I am using testng task. This might help you -

<?xml version="1.0"?>

<project name="Test Project" basedir=".">

        <property name="basedir" value="." />

       
        <property name="SRC" value="${basedir}/src/com/temp" />

       
        <property name="lib" value="${basedir}/lib" />


       
        <property name="build" value="${basedir}/build" /> 

        <target name="init">
               
                <delete dir="${build}" />
                <mkdir dir="${build}" />
        </target>

        <target name="setClassPath">
                <path id="classpath_jars">
                        <pathelement path="${basedir}/" />
                        <fileset dir="${lib}" includes="*.jar" />
                </path>
                <pathconvert pathsep=":" property="test.classpath" refid="classpath_jars" />
        </target>

        <target name="loadTestNG" depends="setClassPath">
               
                <taskdef resource="testngtasks" classpath="${test.classpath}" />
        </target>
 
        <target name="compile" depends="init, setClassPath, loadTestNG">
                <echo message="classpath: ${test.classpath}" />
                <echo message="compiling..." />
                <javac source="1.6" srcdir="${SRC}" fork="true" destdir="${build}" classpath="${test.classpath}" />
        </target>

        <target name="runtest" depends="compile">
                <testng classpath="${test.classpath}:${build}" delegatecommandsystemproperties="true">
                        <xmlfileset dir="${basedir}" includes="testng.xml" />
                </testng>
        </target>

</project>


Try to map it to your project.
And my project structure -

Build File
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: build.xml problem

Ajith
Thanks a  lot tarun
I ll look into it  

Regards
Ajith
Reply | Threaded
Open this post in threaded view
|

Re: build.xml problem

Ajith
In reply to this post by softwaretestingforum
Thanks a  lot tarun
I ll look into it  

Regards
Ajith
Reply | Threaded
Open this post in threaded view
|

Re: build.xml problem

Illusion0Reality
In reply to this post by Ajith
Please let me know,if we should use ant specifically even if we use webdriver.

What is the purpose here for Ant + Selenium + Testng.

I generally use TestNG and Webdriver.
I think, webdriver can do the things what Ant does.

If I can understand what is it for, I can learn new things.
Reply | Threaded
Open this post in threaded view
|

Re: build.xml problem

softwaretestingforum
Administrator
@Illusion0Reality, please post your question in a new thread.
~ seleniumtests.com