Integration with Ant
http://www.javalobby.org/articles/testng/
As with any tool, testing or otherwise, there is often a way to integrate into one of the most popular build tools, Ant. Fortunately, TestNG is no different. To integrate TestNG into your build process, simply add the TestNG jar file to the classpath of Ant, then add the following task into your build file. Keep in mind that you’ll need to change the classpath to point to your build directories.
<taskdef name="testng"
classname="com.beust.testng.TestNGAntTask"
classpathref="project.class.path"/>
<target name="run-tests" depends="compile">
<echo message="running tests"/>
<testng fork="yes" classpathref="project.class.path" outputDir="">
<fileset dir="extras" includes="testing/test-config.xml"/>
<jvmarg value="-ea"/>
</testng>
</target>
The previous block of code works just like the JUnit ant task. It forks a separate JVM process, sets the output directory and the classpath, then runs TestNG with the specified configuration file. Once the tests have been run, a simple set of HTML pages detailing the results of the tests will be output to the directory you specified in the task for outputDir.
http://www.javalobby.org/articles/testng/
As with any tool, testing or otherwise, there is often a way to integrate into one of the most popular build tools, Ant. Fortunately, TestNG is no different. To integrate TestNG into your build process, simply add the TestNG jar file to the classpath of Ant, then add the following task into your build file. Keep in mind that you’ll need to change the classpath to point to your build directories.
<taskdef name="testng"
classname="com.beust.testng.TestNGAntTask"
classpathref="project.class.path"/>
<target name="run-tests" depends="compile">
<echo message="running tests"/>
<testng fork="yes" classpathref="project.class.path" outputDir="">
<fileset dir="extras" includes="testing/test-config.xml"/>
<jvmarg value="-ea"/>
</testng>
</target>
The previous block of code works just like the JUnit ant task. It forks a separate JVM process, sets the output directory and the classpath, then runs TestNG with the specified configuration file. Once the tests have been run, a simple set of HTML pages detailing the results of the tests will be output to the directory you specified in the task for outputDir.
本文介绍了如何将TestNG集成到Ant构建过程中。通过简单的配置步骤,即可在Ant任务中运行TestNG测试用例。文章提供了具体的XML配置示例,包括设置JVM参数、指定输出目录及测试配置文件。
246

被折叠的 条评论
为什么被折叠?



