testNG官方文档翻译-3 testng.xml
你可以通过以下几种不同的方法触发TestNG:
- 用一个testng.xml文件
- 使用ant
- 从命令行触发
这个章节将会介绍testng.xml的格式(你也可以在下面找到关于ant和命令行的内容)。
关于testng.xml当前版本的DTD文件可以在这个网站找到:testng-1.0.dtd
这有一个testng.xml文件的示例:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1" verbose="1" >
<test name="Nopackage" >
<classes>
<class name="NoPackageTest" />
</classes>
</test>
<test name="Regression1">
<classes>
<class name="test.sample.ParameterSample"/>
<class name="test.sample.ParameterTest"/>
</classes>
</test>
</suite>
你也可以通过设置包名来定义xml文件:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1" verbose="1" >
<test name="Regression1" >
<packages>
<package name="test.sample" />
</packages>
</test>
</suite>
在这个例子中,TestNG将会在test.sample包中寻找所有的类,然后将含有TestNG注解的类保留下来执行。
你也可以具体包含或者排除某些组和方法:
<test name="Regression1">
<groups>
<run>
<exclude name="brokenTests" />
<include name="checkinTests" />
</run>
</groups>
<classes>
<class name="test.IndividualMethodsTest">
<methods>
<include name="testMethod" />
</methods>
</class>
</classes>
</test>
你也可以在一个testng.xml文件中定义一些新的组并添加属性,比如是否并行运行测试,需要多少个线程,是否运行JUnit测试等等。
默认情况下,TestNG将会按照XML中放置的顺序运行测试用例,如果你想以随机的顺序运行文件中的类和方法,需要将preserve-order属性设置为false。
<test name="Regression1" preserve-order="false">
<classes>
<class name="test.Test1">
<methods>
<include name="m1" />
<include name="m2" />
</methods>
</class>
<class name="test.Test2" />
</classes>
</test>
请通过查询DTD文件来查看完整的特性。
testNG官方文档翻译-3 testng.xml的更多相关文章
- testNG官方文档翻译-5 测试方法,测试类和测试组
5.1 - 测试方法 测试方法是被 @Test注解的方法.这些方法的返回值会被忽略,除非在testng.xml中将allow-return-values设置为true. <suite allow ...
- testNG官方文档翻译-2 注解
这里是一份TestNG中的可用注解及其属性的概述. 一.用于一个TestNG类的信息配置的注解: @BeforeSuite:被BeforeSuite注解的方法将在其所在suite中的所有test运行之 ...
- testNG官方文档翻译-1 简介
官方文档链接http://testng.org/doc/documentation-main.html 简介 TestNG是一个被设计用来简化广泛的测试需求的测试框架,它既可应用于单元测试(测试一个独 ...
- testNG官方文档翻译-4 运行TestNG
TestNG可以通过不同的方法触发运行: 命令行 ant Eclipse IntelliJ's IDEA
- 【TestNG测试】TestNG、Maven、testng.xml构建测试工程
创建一个maven工程 使用Idea创建maven工程 建立类似如上的工程结构,src/main/java,src/test/java,pom.xml,testng.xml,这里由于我们使用工程是 ...
- TestNG(十五)xml文件实现多线程测试
package com.course.testng.thread; import org.testng.annotations.Test; public class ThreadOnXml { @Te ...
- Spring官方文档翻译(1~6章)
Spring官方文档翻译(1~6章) 转载至 http://blog.csdn.net/tangtong1/article/details/51326887 Spring官方文档.参考中文文档 一.S ...
- TestNG简单的学习-TestNG运行
转载:http://topmanopensource.iteye.com/blog/1983735 TestNG简单的学习-TestNG运行 文档来自官方地址: http://testng.org/d ...
- Retrofit官方文档翻译
Retrofit官方文档翻译 官方文档网址 http://square.github.io/retrofit/ 介绍 Retrofit 将你的 HTTP API 转换为 Java 接口. public ...
随机推荐
- HashCode方法整理
哈希表这个数据结构想必大多数人都不陌生,而且在很多地方都会利用到hash表来提高查找效率.在Java的Object类中有一个方法: 1 public native int hashCode(); 根据 ...
- 怎么知道dll文件是哪个net版本
有时候经常需要查看.dll所使用的.net版本, 因为根本不知道它是使用了1.1还是2.0, 或者是3.0, 这个时候如果需要打开vs.net那又太麻烦, 所以经过长久的摸索, 我找到了一个比较简便的 ...
- upc组队赛5 Bulbs
Bulbs 题目描述 Greg has an m × n grid of Sweet Lightbulbs of Pure Coolness he would like to turn on. Ini ...
- Linux(二)—— Linux配置及指令
目录 Linux配置及指令 一.linux中常用软件的安装 二.主机名和网络 1.修改主机名 2.设置网络 三.关闭防火墙 1.检查防火墙是否开启 2.清除策略 3.永久关闭第一个防火墙 4.关闭第二 ...
- 20140914 1到N自然数排序
1.关于一道1到N自然数排序的华为面试题 http://blog.csdn.net/hongyuan19/article/details/1887656 为什么想进入华为 你对华为了解多少? 华为给我 ...
- FrameWork内核解析之XMS内核管理(一)上篇
阿里P7Android高级架构进阶视频免费学习请点击:https://space.bilibili.com/474380680本篇文章将继续从以下两个内容来介绍XMS内核管理之AMS: [Activi ...
- LeetCode Array Easy 122. Best Time to Buy and Sell Stock II
Description Say you have an array for which the ith element is the price of a given stock on day i. ...
- LeetCode Arrary Easy 35. Search Insert Position 题解
Description Given a sorted array and a target value, return the index if the target is found. If not ...
- redis Sorted set 相关命令
- KiCAD批量修改丝印大小
KiCAD批量修改丝印大小 1.编辑->编辑文本与图片属性 2.范围 选择封装参考,活动 首选选择 “设定为指定值”,然后选择要修改的层,输入想要修改的参数 注意:文本高度与文本宽度比例要适中, ...