PageSourceSearch

https://www.scalatest.org/user_guide

html scalatest.org collected 2026-10-02 02:32:56 UTC 7,258 bytes, 381 lines download raw bytes

1
2
3
4
5
6
7<!DOCTYPE html>
8<html>
9
10<head>
11  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
12  <title>ScalaTest</title>
13  <link rel="Stylesheet" href="/assets/stylesheets/main.css"
14        type="text/css" media="screen"/>
15  <link rel="stylesheet" type="text/css" href="/assets/stylesheets/print.css" media="print" />
16
17  <!-- Global site tag (gtag.js) - Google Analytics -->
vendor: 66 bytes, lines 17-18
17
18  <script async src="https://www.googletagmanager.com/gtag/js?id=
18G-NJWCS90VG5
vendor: 14 bytes, lines 18-19
18"></script>
19  
19<script defer src='/assets/javascripts/gtag.js'></script>
19
20
21</head>
22<body>
23  <div class="UserGuideContainer">
24
25<!-- Top of scalatest.org 660 x 60 [async] -->
26
27<script id="adsArtimaScript" type="text/javascript" src="https://www.artima.com/assets/javascripts/3cbad67e7fa9539151489fd25cf64fdd-ads.js?product=ScalaTest"></script>
27
28
29    <div id="Header">
30
31      
32
33
34<div id="Nav">
35  
36  
37        <a href="/">Home</a>
38  
39 |
40  
41  
42        <a href="/quick_start">Quick Start</a>
43  
44 |
45  
46  
47        <a href="/install">Install</a>
48  
49 |
50  
51  
52        <span><em>User Guide</em></span>
53  
54 |
55  
56  
57        <a href="/at_a_glance">At A Glance</a>
58  
59 |
60  
61  
62        <a href="/scaladoc">Scaladoc</a>
63  
64 |
65  
66  
67        <a href="/supersafe">SuperSafe</a>
68  
69 |
70  
71  
72        <a href="/plus">Plus</a>
73  
74 |
75  <!-- 
76  
77        <a href="/videos">Videos</a>
78  
79 | -->  <!-- Temporarily removed per Bill request  171114 PL -->
80  
81  
82        <a href="/sponsor">Sponsor</a>
83  
84 |
85  
86  
87        <a href="/about">About</a>
88  
89
90</div> <!-- Nav -->
91
92
93    </div> <!-- Header --> 
94
95    <div id="body">
96
97      
98      <div class="message">
99        <a class="scalatestLogo" href="/">
100          <img src="/assets/images/scalaTestLogo.gif"
101               width="400" height="60" alt="ScalaTest"/>
102        </a>
103      </div>
104
105
106      
107  <table width="100%" cellspacing="10px">
108  <tr valign="top">
109  <td align="left" width="20%">
110  
111
112
113<strong>ScalaTest User Guide</strong><br /><br />
114
115  
116    <a href="/user_guide">Getting started</a>
117  
118<br />
119<br />
120
121
122  
123    <a href="/user_guide/selecting_a_style">Selecting testing styles</a>
124  
125<br />
126<br />
127
128
129  
130    <a href="/user_guide/defining_base_classes">Defining base classes</a>
131  
132<br />
133<br />
134
135
136  
137    <a href="/user_guide/writing_your_first_test">Writing your first test</a>
138  
139<br />
140<br />
141
142
143  
144    <a href="/user_guide/using_assertions">Using assertions</a>
145  
146<br />
147<br />
148
149
150
151  
152    <a href="/user_guide/tagging_your_tests">Tagging your tests</a>
153  
154<br />
155<br />
156
157
158  
159    <a href="/user_guide/running_your_tests">Running your tests</a>
160  
161<br />
162<br />
163
164
165  
166    <a href="/user_guide/sharing_fixtures">Sharing fixtures</a>
167  
168<br />
169<br />
170
171
172  
173    <a href="/user_guide/sharing_tests">Sharing tests</a>
174  
175<br />
176<br />
177
178
179  
180    <a href="/user_guide/using_matchers">Using matchers</a>
181  
182<br />
183<br />
184
185
186  
187    <a href="/user_guide/testing_with_mock_objects">Testing with mock objects</a>
188  
189<br />
190<br />
191
192
193  
194    <a href="/user_guide/property_based_testing">Property-based testing</a>
195  
196<br />
197<br />
198
199
200  
201    <a href="/user_guide/async_testing">Asynchronous testing</a>
202  
203<br />
204<br />
205
206
207  
208    <a href="/user_guide/using_scalajs">Using Scala-js</a>
209  
210<br />
211<br />
212
213
214  
215    <a href="/user_guide/using_inside">Using Inside</a>
216  
217<br />
218<br />
219
220
221  
222    <a href="/user_guide/using_OptionValues">Using OptionValues</a>
223  
224<br />
225<br />
226
227
228  
229    <a href="/user_guide/using_EitherValues">Using EitherValues</a>
230  
231<br />
232<br />
233
234
235  
236    <a href="/user_guide/using_PartialFunctionValues">Using PartialFunctionValues</a>
237  
238<br />
239<br />
240
241
242  
243    <a href="/user_guide/using_PrivateMethodTester">Using PrivateMethodTester</a>
244  
245<br />
246<br />
247
248
249  
250    <a href="/user_guide/using_WrapWith">Using WrapWith</a>
251  
252<br />
253<br />
254
255
256  
257    <a href="/user_guide/philosophy_and_design">Philosophy and design</a>
258  
259<br />
260<br />
261
262
263  
264    <a href="/user_guide/migrating_to_30">Migrating to 3.0</a>
265  
266<br />
267<br />
268
269<!--
270
271  
272    <a href="/user_guide/other_goodies">Other goodies</a>
273  
274<br />
275<br />
276
277
278  
279    <a href="/user_guide/customizing_scalatest">Customizing ScalaTest</a>
280  
281<br />
282<br />
283
284-->
285
286
287  </td>
288  <td width="80%">
289  
290
291<div style="text-align: left">
292
293<p>
294This user guide will help you get rolling quickly with ScalaTest. First a brief orientation:
295</p>
296
297<ul>
298<li>The central concept in ScalaTest is the <em>suite</em>, a collection of zero to many tests.</li>
299<li>A <em>test</em> can be anything with a name that can start and either succeed, fail, be pending, or canceled.</li>
300<li>The central unit of composition in ScalaTest is <code>Suite</code>, which represents a suite of tests.</li>
301<li>Trait <code>Suite</code> declares <code>run</code> and other &#8220;lifecycle&#8221; methods that define a default way to write and run tests.</li>
302<li>These lifecycle methods can be overridden to customize how tests are written and run.</li>
303<li>ScalaTest offers <em>style traits</em> that extend <code>Suite</code> and override lifecycle methods to support different testing styles.</li>
304<li>It provides <em>mixin traits</em> that override lifecycle methods of the style traits to address particular testing needs.</li>
305<li>You define test classes by composing <code>Suite</code> style and mixin traits.</li>
306<li>You define test suites by composing <code>Suite</code> instances.</li>
307</ul>
308
309<p>
310To include ScalaTest in your sbt project, simply add this line:
311</p>
312
313<pre class="stHighlighted">
314libraryDependencies += <span class="stQuotedString">
314"org.scalatest"</span> %% <span class="stQuotedString">"scalatest"</span> % <span class="stQuotedString">"3.2.20"</span> % <span class="stQuotedString">"test"</span>
315</pre>
316
317<p>
318To include ScalaTest in your Maven project, use:
319</p>
320
321<pre class="stHighlighted">
322&lt;dependency&gt;
323  &lt;groupId&gt;org.scalatest&lt;/groupId&gt;
324  &lt;artifactId&gt;scalatest_3&lt;/artifactId&gt;
325  &lt;version&gt;3.2.20&lt;/version&gt;
326  &lt;scope&gt;test&lt;/scope&gt;
327&lt;/dependency&gt;
328</pre>
329
330<p>
331For other ways to include ScalaTest in your project, see <a href="/user_guide/running_your_tests">Running your tests</a>.
332</p>
333
334<p>
335Using ScalaTest on your project is as easy as 1, 2, 3:
336</p>
337
338<ol>
339<li><a href="/user_guide/selecting_a_style">Select your testing styles</a>
340<li><a href="/user_guide/defining_base_classes">Define your base classes</a>
341<li><a href="/user_guide/writing_your_first_test">Start writing tests</a>
342</ol>
343
344
345  </td>
346  </tr>
347  </table>
348
349
350    </div> <!-- body -->
351    <div style="font-size: 66%; margin-top: 60px">
352      <p>
353        ScalaTest is brought to you by Bill Venners and Artima.<br />
354        ScalaTest is free, open-source software
355        released under the <a
356        href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache
357        2.0 license</a>.
358      </p>
359
360      <p>
361        If your company loves ScalaTest, please consider <a href="/sponsor">sponsoring the project</a>.
362      </p>
363
364      <p>
365        Copyright &copy; 2009-2026 Artima, Inc. All Rights Reserved.
366      </p>
367
368      <p>
369        <a href="http://www.artima.com" class="no_link_hover">
370          <img src="/assets/images/artima100Black.png"
371               style="margin-top: 2px" width="100" height="38" alt="artima"/>
372        </a>
373      </p>
374    </div> <!-- style="..." -->
375  </div> <!-- Container -->
376</body>
377</html>
378
379
380
381

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.