testng xml 示例
TestNG的DTD检查文件:http://testng.org/testng-1.0.dtd.php
更多testng配置及说明,请移步http://testdoc.org/docmaster?pid=111
testng.xml文件结构:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="suitename" junit="false" verbose="3" parallel="false" thread-count="5" configfailurepolicy="<span style="font-family:Arial;"><span style="font-size: 14px; line-height: 26px;">skip</span></span>" annotations="javadoc" time-out="10000" skipfailedinvocationcounts="true" data-provider-thread-count="5" object-factory="classname" allow-return-values="true"> <!-- name参数为必须 -->
<suite-files>
<suite-file path="/path/to/suitefile1"></suite-file> <!-- path参数为必须 -->
<suite-file path="/path/to/suitefile2"></suite-file>
</suite-files>
<parameter name="par1" value="value1"></parameter> <!-- name, value参数为必须 -->
<parameter name="par2" value="value2"></parameter>
<method-selectors>
<method-selector>
<selector-class name="classname" priority="1"></selector-class> <!-- name参数为必须 -->
<script language="java"></script> <!-- language参数为必须 -->
</method-selector>
</method-selectors>
<test name="testename" junit="false" verbose="3" parallel="false" thread-count="5" annotations="javadoc" time-out="10000" enabled="true" skipfailedinvocationcounts="true" preserve-order="true" allow-return-values="true"> <!-- name参数为必须 -->
<parameter name="par1" value="value1"></parameter> <!-- name, value参数为必须 -->
<parameter name="par2" value="value2"></parameter>
<groups>
<define name="xxx"> <!-- name参数为必须 -->
<include name="" description="" invocation-numbers="" /> <!-- name参数为必须 -->
<include name="" description="" invocation-numbers="" />
</define>
<run>
<include name="" /> <!-- name参数为必须 -->
<exclude name="" /> <!-- name参数为必须 -->
</run>
<dependencies>
<group name="" depends-on=""></group> <!-- name,depends-on均为参数为必须 -->
<group name="" depends-on=""></group>
</dependencies>
</groups>
<classes>
<class name="classname"> <!-- name参数为必须 -->
<methods>
<parameter name="par3" value="value3"></parameter>
<include name="" description="" invocation-numbers=""></include>
<exclude name=""></exclude>
</methods>
<methods></methods>
</class>
</classes>
<packages>
<package name="" /> <!-- name参数为必须 -->
<package name="">
<include name="" description="" invocation-numbers=""></include>
<exclude name=""></exclude>
</package>
</packages>
<listeners>
<listener class-name="classname1" /> <!-- name参数为必须 -->
<listener class-name="classname2" />
</listeners>
</test>
<test></test>
</suite>
testng.xml文件节点属性说明:
suite属性说明:
@name: suite的名称,必须参数
@junit:是否以Junit模式运行,可选值(true | false),默认"false"
@verbose:命令行信息打印等级,不会影响测试报告输出内容;可选值(1|2|3|4|5)
@parallel:是否多线程并发运行测试;可选值(false | methods | tests | classes | instances),默认 "false"
@thread-count:当为并发执行时的线程池数量,默认为"5"
@configfailurepolicy:一旦Before/After Class/Methods这些方法失败后,是继续执行测试还是跳过测试;可选值 (skip | continue),默认"skip"
@annotations:获取注解的位置,如果为"javadoc", 则使用javadoc注解,否则使用jdk注解
@time-out:为具体执行单元设定一个超时时间,具体参照parallel的执行单元设置;单位为毫秒
@skipfailedinvocationcounts:是否跳过失败的调用,可选值(true | false),默认"false"
@data-provider-thread-count:并发执行时data-provider的线程池数量,默认为"10"
@object-factory:一个实现IObjectFactory接口的类,用来实例测试对象
@allow-return-values:是否允许返回函数值,可选值(true | false),默认"false"
@preserve-order:顺序执行开关,可选值(true | false) "true"
@group-by-instances:是否按实例分组,可选值(true | false) "false"
test属性说明:
@name:test的名字,必选参数;测试报告中会有体现
@junit:是否以Junit模式运行,可选值(true | false),默认"false"
@verbose:命令行信息打印等级,不会影响测试报告输出内容;可选值(1|2|3|4|5)
@parallel:是否多线程并发运行测试;可选值(false | methods | tests | classes | instances),默认 "false"
@thread-count:当为并发执行时的线程池数量,默认为"5"
@annotations:获取注解的位置,如果为"javadoc", 则使用javadoc注解,否则使用jdk5注解
@time-out:为具体执行单元设定一个超时时间,具体参照parallel的执行单元设置;单位为毫秒
@enabled:设置当前test是否生效,可选值(true | false),默认"true"
@skipfailedinvocationcounts:是否跳过失败的调用,可选值(true | false),默认"false"
@preserve-order:顺序执行开关,可选值(true | false) "true"
@group-by-instances:是否按实例分组,可选值(true | false) "false"
@allow-return-values:是否允许返回函数值,可选值(true | false),默认"false"
可以允许的实例
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default suite" parallel="classes" thread-count="1">
<test verbose="2" name="Default test">
<classes>
<class name="com.fc.htgl.testcases.TestOrder">
<methods>
<include name="getReturnExpressSF"></include>
<include name="getReturnExpressSTO"></include>
</methods>
</class>
<class name="com.fc.htgl.testcases.TestSendExpress">
<methods>
<include name="testCustomerGetExpressSF"></include>
<include name="testCustomerGetExpressSTO"></include>
</methods> </class>
</classes> </test> <!-- Default test -->
</suite> <!-- Default suite -->
testng xml 示例的更多相关文章
- TestNG+Maven+IDEA 自动化测试(二) TestNG.xml
示例代码: https://github.com/ryan255/TestNG-Demo 项目代码结构参考上一章 TestNG+Maven+IDEA 自动化测试(一) 环境搭建 maven插件引入 & ...
- TestNG的testng.xml配置概述
TestNG提供的annotaions用来辅助定义测试类. TestNG的testng.xml配置文件用来辅助定义执行什么样的测试,即testng.xml更像是一个测试规划. testng.xml配置 ...
- testNG官方文档翻译-3 testng.xml
你可以通过以下几种不同的方法触发TestNG: 用一个testng.xml文件 使用ant 从命令行触发 这个章节将会介绍testng.xml的格式(你也可以在下面找到关于ant和命令行的内容). 关 ...
- testng教程之testng.xml的配置和使用,以及参数传递
昨天学习了一下testng基础教程,http://www.cnblogs.com/tobecrazy/p/4579414.html 昨天主要学习的是testng 的annotation基本用法和生命周 ...
- TestNG官方文档中文版(3)-testng.xml
TestNG的官方文档的中文翻译版第3章,原文请见 http://testng.org/doc/documentation-main.html 3 - testng.xml 调用TestNG由几种不同 ...
- testng.xml文件结构组成及节点属性说明
TestNG的DTD检查文件:http://testng.org/testng-1.0.dtd.PHP 更多testng配置及说明,请移步http://testdoc.org/docmaster?pi ...
- testng.xml顺序执行多个case配置
testng.xml顺序执行多个case配置 项目结构如图:
- testng.xml创建及解析
项目右键---TestNG -----> Convert to TestNG 会自动产生一个testng.xml的文件 http://www.cnblogs.com/choosewang/art ...
- TestNG中同一个类中执行多个test()方法如何配置testng.xml
public class IndexInfo extends BaseTesting{ private IndexPage IndexPage1;// private AddEquipmentInfo ...
随机推荐
- FoxOne---一个快速高效的BS框架--(2)
FoxOne---一个快速高效的BS框架--(1) FoxOne---一个快速高效的BS框架--(2) FoxOne---一个快速高效的BS框架--(3) FoxOne---一个快速高效的BS框架-- ...
- REST深入浅出
不知你是否意识到,围绕着什么才是实现异构的应用到应用通信的“正确”方式,一场争论正进行的如火如荼:虽然当前主流的方式明显地集中在基于SOAP.WSDL和WS-*规范的Web Services领域,但也 ...
- SQLite中不支持的sql语法
今天很自然的在写Sql语句的时候用了Top,一开始没发现问题,因为我从数据库读出的值正好是0,而我习惯变量定义的时候也都赋值0,可是到我不要0的时候我就发现问题了.后来才知道,可爱的小sqlite竟然 ...
- JavaScripts学习日记——DOM SAX JAXP DEMO4J XPath
今日关键词: XML解析器 DOM SAX JAXP DEMO4J XPath XML解析器 1.解析器概述 什么是解析器 XML是保存数据的文件,XML中保存的数据也需要被程序读取然后使用.那么程序 ...
- sql server里一些常用的查询
查看表的创建和更改时间: select * from sys.tables 查询数据库的创建时间: select * from sys.databases where name in ('数据 ...
- 前端 JavaScript基础
前言 JavaScript 是属于网络的脚本语言,被数百万计的网页用来改进设计.验证表单.检测浏览器.创建cookies,以及更多的应用. 一.如何编写 1.存在形式 方式一:存在js文件中,即写入j ...
- mvc自带的异步表单提交
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- hdu5391 Zball in Tina Town(威尔逊定理)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Zball in Tina Town Time Limit: 3000/1500 ...
- javascript改变背景/字体颜色(Through the javascript to change the background and font color)
鼠标移动到.移出DIV时修改DIV的颜色: 1.Change the font and Div background color--function <div style="width ...
- mysql foreign key 外键
ALTER TABLE `fd_rel_customer_doctor` ADD CONSTRAINT `FK_fd_rel_customer_doctor_1` FOREIGN KEY (`CUST ...