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 示例的更多相关文章

  1. TestNG+Maven+IDEA 自动化测试(二) TestNG.xml

    示例代码: https://github.com/ryan255/TestNG-Demo 项目代码结构参考上一章 TestNG+Maven+IDEA 自动化测试(一) 环境搭建 maven插件引入 & ...

  2. TestNG的testng.xml配置概述

    TestNG提供的annotaions用来辅助定义测试类. TestNG的testng.xml配置文件用来辅助定义执行什么样的测试,即testng.xml更像是一个测试规划. testng.xml配置 ...

  3. testNG官方文档翻译-3 testng.xml

    你可以通过以下几种不同的方法触发TestNG: 用一个testng.xml文件 使用ant 从命令行触发 这个章节将会介绍testng.xml的格式(你也可以在下面找到关于ant和命令行的内容). 关 ...

  4. testng教程之testng.xml的配置和使用,以及参数传递

    昨天学习了一下testng基础教程,http://www.cnblogs.com/tobecrazy/p/4579414.html 昨天主要学习的是testng 的annotation基本用法和生命周 ...

  5. TestNG官方文档中文版(3)-testng.xml

    TestNG的官方文档的中文翻译版第3章,原文请见 http://testng.org/doc/documentation-main.html 3 - testng.xml 调用TestNG由几种不同 ...

  6. testng.xml文件结构组成及节点属性说明

    TestNG的DTD检查文件:http://testng.org/testng-1.0.dtd.PHP 更多testng配置及说明,请移步http://testdoc.org/docmaster?pi ...

  7. testng.xml顺序执行多个case配置

    testng.xml顺序执行多个case配置 项目结构如图:

  8. testng.xml创建及解析

    项目右键---TestNG -----> Convert to TestNG 会自动产生一个testng.xml的文件 http://www.cnblogs.com/choosewang/art ...

  9. TestNG中同一个类中执行多个test()方法如何配置testng.xml

    public class IndexInfo extends BaseTesting{ private IndexPage IndexPage1;// private AddEquipmentInfo ...

随机推荐

  1. Win32函数Sleep的精度测试

    用了三种方法,第一种使用高精度性能计数器:第二种是使用多媒体定时器,另一种是<Windows图形编程>里提供的CPU周期来获取.推荐第一种方式测量: 先看第一种: #include < ...

  2. (一)MVP设计模式

    一.MVP介绍      随着UI创建技术的功能日益增强,UI层也履行着越来越多的职责.为了更好地细分视图(View)与模型(Model)的功能,让View专注于处理数据的可视化以及与用户的交互,同时 ...

  3. Java基础知识强化62:Arrays工具类之概述和使用

    1. Arrays工具类: Arrays这个类包含操作数组(比如排序和查找)的各种方法. 2. Arrays的方法: (1)toString方法:把数组转成字符串 public static Stri ...

  4. samba服务简介

    1.1 Samba 概述Samba主要用于Windows和Linux之间的文件共享,也一样用于Linux和Linux之间的共享文件:不过对于Linux和Linux之间共享文件有更好的网络文件系统NFS ...

  5. R语言编程艺术# 矩阵(matrix)和数组(array)

    矩阵(matrix)是一种特殊的向量,包含两个附加的属性:行数和列数.所以矩阵也是和向量一样,有模式(数据类型)的概念.(但反过来,向量却不能看作是只有一列或一行的矩阵. 数组(array)是R里更一 ...

  6. (转)几种HtmlEncode的区别

    一.C#中的编码 HttpUtility.HtmlDecode.HttpUtility.HtmlEncode与Server.HtmlDecode.Server.HtmlEncode与HttpServe ...

  7. Request.ServerVariables 服务器环境变量

    Request.ServerVariables["Url"] 返回服务器地址 Request.ServerVariables["Path_Info"] 客户端提 ...

  8. const的重载

    class A { private: int a; public: A(int x) :a(x){}//构造函数并不能重载 void display(){ cout << "no ...

  9. 初次窥见智能指针auto_ptr和shared_ptr

    #include <memory>//shared_ptr要用的头文件 using namespace std; class A //测试auto_ptr和shared_ptr的delet ...

  10. UVALive 5792 Diccionário Portuñol

    字符串匹配问题 有n个a串个m个b串,讲a的前缀和b的后缀粘在一起有多少个不同的新串. 首先求不同的前缀和后缀肯定好求了,就用字典树分别存一下a个倒过来的b. 那个问题就是解决例如,abcd,和bcd ...