-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtestng_xml.html
144 lines (140 loc) · 4.77 KB
/
testng_xml.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.18">
<title>testng.xml</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<link rel="stylesheet" href="./asciidoctor.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css">
</head>
<body class="article toc2 toc-left">
<div id="header">
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel2">
<li><a href="#_testng_xml"><code>testng.xml</code></a></li>
</ul>
</div>
</div>
<div id="content">
<div class="sect2">
<h3 id="_testng_xml"><code>testng.xml</code></h3>
<div class="paragraph">
<p>You can invoke TestNG in several different ways:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>With a <code>testng.xml</code> file</p>
</li>
<li>
<p>With <code>ant</code></p>
</li>
<li>
<p>From the command line</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>This section describes the format of <code>testng.xml</code> (you will find documentation on ant and the command line below).</p>
</div>
<div class="paragraph">
<p>The current DTD for testng.xml can be found on the main Web site: <a href="https://testng.org/testng-1.0.dtd">testng-1.0.dtd</a>.
Here is an example testng.xml file:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code data-lang="xml"><!DOCTYPE suite SYSTEM "https://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></code></pre>
</div>
</div>
<div class="paragraph">
<p>You can specify package names instead of class names:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code data-lang="xml"><!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite1" verbose="1">
<test name="Regression1">
<packages>
<package name="test.sample"/>
</packages>
</test>
</suite></code></pre>
</div>
</div>
<div class="paragraph">
<p>In this example, TestNG will look at all the classes in the package <code>test.sample</code> and will retain only classes that have TestNG annotations.</p>
</div>
<div class="paragraph">
<p>You can also specify groups and methods to be included and excluded:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code data-lang="xml"><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></code></pre>
</div>
</div>
<div class="paragraph">
<p>You can also define new groups inside <code>testng.xml</code> and specify additional details in attributes, such as whether to run the tests in parallel, how many threads to use, whether you are running JUnit tests, etc…​</p>
</div>
<div class="paragraph">
<p>By default, TestNG will run your tests in the order they are found in the XML file. If you want the classes and methods listed in this file to be run in an unpredictable order, set the <code>preserve-order</code> attribute to false.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code data-lang="xml"><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></code></pre>
</div>
</div>
<div class="paragraph">
<p>Please see the DTD for a complete list of the features, or read on.</p>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2025-02-27 18:51:48 UTC
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/run_prettify.min.js"></script>
</body>
</html>