如何使用testng.xml

时间:2011-04-27 13:14:37

标签: xml selenium

您好我是selenium的新手,现在我想使用selenium rc和eclipse Ide运行我的测试套件 我执行时使用了ant,那时我在testNG.xml中出错了。所以请告诉我任何一个如何使用testng.xml并给我一个testng.xml样本

这是我的Build.xml

        

<property name="lib.dir"   value="/softwares/lib"/>
<property name="src.dir" value="/softwares/src" />

                                                                                                                                                                                                                                                                          

<target name="run_testNG" description="Run TestNG">
    <testng classpathref="compile.classpath" haltOnfailure="false">
        <xmlfileset dir="/softwares/cruisecontrol-bin-2.8.3/run_test/" includes="testng.xml" />
    </testng>
</target>
<target name="start-server">
    <java jar="/softwares/selenium/selenium-server-standalone-2.0b2.jar" fork="true" spawn="true">
        <arg line="-timeout 30"/>
        <jvmarg value="-Dhttp.proxyHost=proxy.corporate.com"/>
        <jvmarg value="-Dhttp.proxyPort=3128"/>
    </java>
</target>
<target name="stop-server">
    <get taskname="selenium-shutdown"
        src="http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer"
        dest="result.txt" ignoreerrors="true" />
    <echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
</target>
<taskdef resource="testngtasks" classpath="/softwares/selenium/selenium-2.0b2/libs/testng-5.14.1.jar" />

===========================

这是我的testng.xml

                         

===================

我们遇到以下错误:

Buildfile: build.xml
prepare:
compile:
run_test:
  [waitfor] Wait for proxy server launch
start-server:
run_testNG:
   [testng] [TestNG] [ERROR] 
   [testng] Cannot find class in classpath: com.example.tests
   [testng] The tests failed.
stop-server:
[selenium-shutdown] Getting: http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
[selenium-shutdown] To: /softwares/cruisecontrol-bin-2.8.3/run_test/result.txt
[selenium-shutdown] DGF Errors during shutdown are expected
BUILD SUCCESSFUL

请帮助我.....我们收到的错误是“在课程路径中找不到课程”

1 个答案:

答案 0 :(得分:0)

确保启动TestNG的类路径包含您的类。