`
dearwolf
  • 浏览: 339300 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

integrate testng with ant

阅读更多
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.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics