File: index.html

package info (click to toggle)
testng 5.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 8,308 kB
  • ctags: 11,519
  • sloc: java: 48,416; xml: 3,234; makefile: 54; sh: 13
file content (226 lines) | stat: -rw-r--r-- 7,903 bytes parent folder | download | duplicates (2)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<html>
  <head>
    <title>TestNG - Welcome</title>
      <link rel="stylesheet" href="testng.css" type="text/css" />
      <link type="text/css" rel="stylesheet" href="http://beust.com/beust.css"  />
      <script type="text/javascript" src="http://beust.com/prettify.js"></script>
      <script type="text/javascript" src="http://testng.org/doc/banner.js"></script>

      <script type="text/javascript" src="http://beust.com/scripts/shCore.js"></script>
      <script type="text/javascript" src="http://beust.com/scripts/shBrushJava.js"></script>
      <script type="text/javascript" src="http://beust.com/scripts/shBrushXml.js"></script>
      <script type="text/javascript" src="http://beust.com/scripts/shBrushBash.js"></script>
      <script type="text/javascript" src="http://beust.com/scripts/shBrushPlain.js"></script>
      <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shCore.css"/>
      <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shThemeCedric.css"/>
      <script type="text/javascript">
        SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
        SyntaxHighlighter.defaults['gutter'] = false;
        SyntaxHighlighter.all();
      </script>
    </head>

<body onload="prettyPrint()">

<script type="text/javascript">
   displayMenu("index.html");
</script>


<h2 >TestNG</h2>
<h2>Our book is now available</h2>
<p align="center">
<a href="book.html">
<img border="0" src="http://beust.com/pics/book-cover.jpg" />
</a>
</p>
<p align="center">
<a href="book.html">Click for more details.</a>
</p>



<p align="right"><font size="-2"><em>C&eacute;dric Beust (cedric at beust.com)<br>
Current version: 5.10<br>
Created:&nbsp;April 27th, 2004<br>
Last Modified:&nbsp; November 7th, 2009</em></font></p>


<p>TestNG is a testing framework inspired from JUnit and NUnit but introducing
some new functionalities that make it more powerful and easier to use, such as:</p>
<ul>
       <li>JDK 5 Annotations (JDK 1.4 is also supported with JavaDoc annotations).
       </li>
       <li>Flexible test configuration.
       </li>
       <li>Support for data-driven testing (with <tt>@DataProvider</tt>).</li>
       <li>Support for parameters.</li>
               <li>Allows distribution of tests on slave machines.</li>
       <li>Powerful execution model (no more <tt>TestSuite</tt>).
       </li>
       <li>Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven,
       etc...).
       </li>
       <li>Embeds BeanShell for further flexibility.
       </li>
       <li>Default JDK functions for runtime and logging (no dependencies).
       </li>
       <li>Dependent methods for application server testing.</li>
</ul>
<p>TestNG is designed to cover all categories of tests:&nbsp; unit, functional,
end-to-end, integration, etc...</p>
<p>I started TestNG out of frustration for some JUnit deficiencies which I have
documented on my weblog <a href="http://www.beust.com/weblog/archives/000173.html">here</a> and <a href="http://www.beust.com/weblog/archives/000082.html">here</a>
Reading these entries might give you a better idea of the goal I am trying to
achieve with TestNG.&nbsp; You can also check out a quick
<a href="http://www.beust.com/weblog/archives/000176.html">overview of the main
features</a> and an <a href="http://www.beust.com/weblog/archives/000170.html">
article</a> describing a very concrete example where the combined use of several
TestNG's features provides for a very intuitive and maintainable testing design.</p>
<p>Here is a very simple test:</p>

<pre class="brush: java">
package example1;

import org.testng.annotations.*;

public class SimpleTest {

 @BeforeClass
 public void setUp() {
   // code that will be invoked when this test is instantiated
 }

 @Test(groups = { "fast" })
 public void aFastTest() {
   System.out.println("Fast test");
 }

 @Test(groups = { "slow" })
 public void aSlowTest() {
    System.out.println("Slow test");
 }

}
</pre>

The method <tt>setUp()</tt> will be invoked after the test class has been built and before
any test method is run.&nbsp; In this example, we will be running the group
fast, so <tt>aFastTest()</tt> will be invoked while <tt>aSlowTest()</tt> will be
skipped.<p>
<!-------------------------------------

 WRITING A TEST

 ------------------------------------>

Things to note:</p><ul>
       <li>No need to extend a class or implement an interface.</li><li>Even though the example above uses the JUnit conventions, our methods
       can be called any name you like, it's the annotations that tell TestNG what
       they are.</li><li>A test method can belong to one or several groups.</li></ul>

       <p>

Once you have compiled your test class into the <tt>build</tt> directory, you
can invoke your test with the command line, an ant task (shown below) or an XML
file:


<pre class="brush: xml">
&lt;project default="test"&gt;

 &lt;path id="cp"&gt;
   &lt;pathelement location="lib/testng-testng-4.4-jdk15.jar"/&gt;
   &lt;pathelement location="build"/&gt;
 &lt;/path&gt;

 &lt;taskdef name="testng" classpathref="cp"
          classname="org.testng.TestNGAntTask" /&gt;

 &lt;target name="test"&gt;
   &lt;testng classpathref="cp" groups="fast"&gt;
     &lt;classfileset dir="build" includes="example1/*.class"/&gt;
   &lt;/testng&gt;
 &lt;/target&gt;

&lt;/project&gt;
</pre>

Use ant to invoke it:

<pre class="brush: text">
c:&gt; ant
Buildfile: build.xml

test:
[testng] Fast test
[testng] ===============================================
[testng] Suite for Command line test
[testng] Total tests run: 1, Failures: 0, Skips: 0
[testng] ===============================================


BUILD SUCCESSFUL
Total time: 4 seconds
</pre>

Then you can browse the result of your tests:

<pre class="brush: text">
start test-output\index.html (on Windows)
</pre>

<h3><a name="requirements">Requirements</a></h3>
<p>TestNG runs on JDK 1.4 and 5.&nbsp; The examples shown in this
documentation assume JDK 5 and therefore, use JDK 5 annotations, but they
can easily be translated to JDK 1.4 JavaDoc-type annotations.&nbsp; See the JDK
1.4 section for details.</p>

<h3><a name="mailing-lists">Mailing-lists</a></h3>
<p>The users mailing-list can be found in two different places:</p>
<ul>
       <li>As an email mailing-list on
       <a href="http://groups-beta.google.com/group/testng-users/">Google Groups</a>.</li>
       <li>As a <a href="http://testng.org/forums">Web
       forum</a>, kindly hosted by <a href="http://opensymphony.com">Open Symphony</a>.</li>
</ul>
<p>The Web forum and the mailing-list are connected to each other, so you only
need to subscribe to one.</p>
<h3><a name="locations-projects">Locations of the projects</a></h3>
<p>If you are interested in contributing to TestNG or one of the IDE plug-ins,
you will find them in the following locations:</p>
<ul>
       <li><a href="http://code.google.com/p/testng/">TestNG</a></li>
       <li><a href="http://code.google.com/p/testng-eclipse">Eclipse plug-in</a></li>
       <li><a href="http://www.javaforge.com/proj/summary.do?proj_id=4">IDEA
       IntelliJ plug-in</a></li>
       <li><a href="http://blogs.sun.com/xzajo?entry=test_ng_plugin_for_netbeans">
       NetBeans plug-in</a></li>
</ul>
<h3><a name="bug-reports">Bug reports</a></h3>
<p>The TestNG project is administered by
<a href="http://jira.opensymphony.com/browse/TESTNG">OpenSymphony's JIRA</a>.
</p>

<!-------------------------------------

 REQUIREMENTS

 ------------------------------------>
<p>For more information, you can either <a href="download.html">download TestNG</a>,
read the <a href="documentation-main.html">manual</a> or browse the links at the
<a href="#top">top</a>.</p>


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-238215-2";
urchinTracker();
</script>


</body>

</html>