TestNg + ReprotNG Commandline

来源:互联网 发布:欧文体测数据 编辑:程序博客网 时间:2024/05/16 14:12

Execute test cases by commandline for TestNG


1. Add reportng listener to Testng.xml

a. ReportNG need add jars: reportng-*.jar, Velocity-*.jar, guice-3.0.jar

add below Listener to testng.xml

    org.uncommons.reportng.HTMLReporter
    org.uncommons.reportng.JUnitXMLReporter

like:

[html] view plaincopyprint?
  1. <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >  
  2. <suite name="Online Test" verbose="1" preserve-order="true">>  
  3.   <listeners>  
  4.     <listener class-name="org.uncommons.reportng.HTMLReporter" />  
  5.   </listeners>  
  6. ...  

2. Execute ways:

2.1 Execute in Eclipse,


b. Set disable default report as false: Eclipse Project-> Properties -> TestNG -> Diable deafult

listeners.

c. Run as TestNg


2.2 Execute in commandline:

bat file like:

[plain] view plaincopyprint?
  1. @echo off  
  2. set LIB=E:\Libs  
  3.   
  4. set CLASSPATH=%LIB%\Guice\guice-3.0.jar;%LIB%\Velocity\velocity-1.7\velocity-1.7-dep.jar;  
  5.   
  6. %LIB%\Selenium\selenium-server-standalone-2.42.2.jar;%LIB%\ReportNg\reportng-1.1.4.jar;E:\Test\bin\;E:\RZC\Code\TestCore\bin\  
  7.   
  8.   
  9.   
  10. java org.testng.TestNG E:\Test\src\OnlineTest.xml -d %cd%\TestNG-tempResult  

set result output dir use -d command.



0 0