testng xml 示例

2024-03-31 05:08
文章标签 xml 示例 testng

本文主要是介绍testng xml 示例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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" 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>
</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 示例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/863466

相关文章

Spring Boot 集成 Solr 的详细示例

《SpringBoot集成Solr的详细示例》:本文主要介绍SpringBoot集成Solr的详细示例,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 目录环境准备添加依赖配置 Solr 连接定义实体类编写 Repository 接口创建 Service 与 Controller示例运行

Python多进程、多线程、协程典型示例解析(最新推荐)

《Python多进程、多线程、协程典型示例解析(最新推荐)》:本文主要介绍Python多进程、多线程、协程典型示例解析(最新推荐),本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定... 目录一、multiprocessing(多进程)1. 模块简介2. 案例详解:并行计算平方和3. 实现逻

Vue中插槽slot的使用示例详解

《Vue中插槽slot的使用示例详解》:本文主要介绍Vue中插槽slot的使用示例详解,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、插槽是什么二、插槽分类2.1 匿名插槽2.2 具名插槽2.3 作用域插槽三、插槽的基本使用3.1 匿名插槽

uniapp小程序中实现无缝衔接滚动效果代码示例

《uniapp小程序中实现无缝衔接滚动效果代码示例》:本文主要介绍uniapp小程序中实现无缝衔接滚动效果的相关资料,该方法可以实现滚动内容中字的不同的颜色更改,并且可以根据需要进行艺术化更改和自... 组件滚动通知只能实现简单的滚动效果,不能实现滚动内容中的字进行不同颜色的更改,下面实现一个无缝衔接的滚动

C#通过进程调用外部应用的实现示例

《C#通过进程调用外部应用的实现示例》本文主要介绍了C#通过进程调用外部应用的实现示例,以WINFORM应用程序为例,在C#应用程序中调用PYTHON程序,具有一定的参考价值,感兴趣的可以了解一下... 目录窗口程序类进程信息类 系统设置类 以WINFORM应用程序为例,在C#应用程序中调用python程序

利用Python实现可回滚方案的示例代码

《利用Python实现可回滚方案的示例代码》很多项目翻车不是因为不会做,而是走错了方向却没法回头,技术选型失败的风险我们都清楚,但真正能提前规划“回滚方案”的人不多,本文从实际项目出发,教你如何用Py... 目录描述题解答案(核心思路)题解代码分析第一步:抽象缓存接口第二步:实现两个版本第三步:根据 Fea

Java计算经纬度距离的示例代码

《Java计算经纬度距离的示例代码》在Java中计算两个经纬度之间的距离,可以使用多种方法(代码示例均返回米为单位),文中整理了常用的5种方法,感兴趣的小伙伴可以了解一下... 目录1. Haversine公式(中等精度,推荐通用场景)2. 球面余弦定理(简单但精度较低)3. Vincenty公式(高精度,

QT6中绘制UI的两种方法详解与示例代码

《QT6中绘制UI的两种方法详解与示例代码》Qt6提供了两种主要的UI绘制技术:​​QML(QtMeta-ObjectLanguage)​​和​​C++Widgets​​,这两种技术各有优势,适用于不... 目录一、QML 技术详解1.1 QML 简介1.2 QML 的核心概念1.3 QML 示例:简单按钮

SQL Server中的PIVOT与UNPIVOT用法具体示例详解

《SQLServer中的PIVOT与UNPIVOT用法具体示例详解》这篇文章主要给大家介绍了关于SQLServer中的PIVOT与UNPIVOT用法的具体示例,SQLServer中PIVOT和U... 目录引言一、PIVOT:将行转换为列核心作用语法结构实战示例二、UNPIVOT:将列编程转换为行核心作用语

Python logging模块使用示例详解

《Pythonlogging模块使用示例详解》Python的logging模块是一个灵活且强大的日志记录工具,广泛应用于应用程序的调试、运行监控和问题排查,下面给大家介绍Pythonlogging模... 目录一、为什么使用 logging 模块?二、核心组件三、日志级别四、基本使用步骤五、快速配置(bas