CINXE.COM
ScalaTest
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <title>ScalaTest</title> <link rel="Stylesheet" href="/assets/stylesheets/main.css" type="text/css" media="screen"/> <link rel="stylesheet" type="text/css" href="/assets/stylesheets/print.css" media="print" /> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-NJWCS90VG5"></script> <script defer src='/assets/javascripts/gtag.js'></script> </head> <body> <div class="UserGuideContainer"> <!-- Top of scalatest.org 660 x 60 [async] --> <script id="adsArtimaScript" type="text/javascript" src="https://www.artima.com/assets/javascripts/4ca150665e51d0b1c3890ca1b891c507-ads.js?product=ScalaTest"></script> <div id="Header"> <div id="Nav"> <a href="/">Home</a> | <a href="/quick_start">Quick Start</a> | <a href="/install">Install</a> | <span><em>User Guide</em></span> | <a href="/at_a_glance">At A Glance</a> | <a href="/scaladoc">Scaladoc</a> | <a href="/supersafe">SuperSafe</a> | <a href="/plus">Plus</a> | <!-- <a href="/videos">Videos</a> | --> <!-- Temporarily removed per Bill request 171114 PL --> <a href="/donate">Donate</a> | <a href="/about">About</a> </div> <!-- Nav --> </div> <!-- Header --> <div id="body"> <div class="message"> <a class="scalatestLogo" href="/"> <img src="/assets/images/scalaTestLogo.gif" width="400" height="60" alt="ScalaTest"/> </a> </div> <table width="100%" cellspacing="10px"> <tr valign="top"> <td align="left" width="20%"> <strong>ScalaTest User Guide</strong><br /><br /> <a href="/user_guide">Getting started</a> <br /> <br /> <a href="/user_guide/selecting_a_style">Selecting testing styles</a> <br /> <br /> <a href="/user_guide/defining_base_classes">Defining base classes</a> <br /> <br /> <a href="/user_guide/writing_your_first_test">Writing your first test</a> <br /> <br /> <a href="/user_guide/using_assertions">Using assertions</a> <br /> <br /> <a href="/user_guide/tagging_your_tests">Tagging your tests</a> <br /> <br /> <a href="/user_guide/running_your_tests">Running your tests</a> <br /> <br /> <a href="/user_guide/sharing_fixtures">Sharing fixtures</a> <br /> <br /> <a href="/user_guide/sharing_tests">Sharing tests</a> <br /> <br /> <a href="/user_guide/using_matchers">Using matchers</a> <br /> <br /> <a href="/user_guide/testing_with_mock_objects">Testing with mock objects</a> <br /> <br /> <a href="/user_guide/property_based_testing">Property-based testing</a> <br /> <br /> <a href="/user_guide/async_testing">Asynchronous testing</a> <br /> <br /> <a href="/user_guide/using_scalajs">Using Scala-js</a> <br /> <br /> <a href="/user_guide/using_inside">Using Inside</a> <br /> <br /> <a href="/user_guide/using_OptionValues">Using OptionValues</a> <br /> <br /> <a href="/user_guide/using_EitherValues">Using EitherValues</a> <br /> <br /> <a href="/user_guide/using_PartialFunctionValues">Using PartialFunctionValues</a> <br /> <br /> <a href="/user_guide/using_PrivateMethodTester">Using PrivateMethodTester</a> <br /> <br /> <a href="/user_guide/using_WrapWith">Using WrapWith</a> <br /> <br /> <a href="/user_guide/philosophy_and_design">Philosophy and design</a> <br /> <br /> <a href="/user_guide/migrating_to_30">Migrating to 3.0</a> <br /> <br /> <!-- <a href="/user_guide/other_goodies">Other goodies</a> <br /> <br /> <a href="/user_guide/customizing_scalatest">Customizing ScalaTest</a> <br /> <br /> --> </td> <td width="80%"> <div style="text-align: left"> <p> This user guide will help you get rolling quickly with ScalaTest. First a brief orientation: </p> <ul> <li>The central concept in ScalaTest is the <em>suite</em>, a collection of zero to many tests.</li> <li>A <em>test</em> can be anything with a name that can start and either succeed, fail, be pending, or canceled.</li> <li>The central unit of composition in ScalaTest is <code>Suite</code>, which represents a suite of tests.</li> <li>Trait <code>Suite</code> declares <code>run</code> and other “lifecycle” methods that define a default way to write and run tests.</li> <li>These lifecycle methods can be overridden to customize how tests are written and run.</li> <li>ScalaTest offers <em>style traits</em> that extend <code>Suite</code> and override lifecycle methods to support different testing styles.</li> <li>It provides <em>mixin traits</em> that override lifecycle methods of the style traits to address particular testing needs.</li> <li>You define test classes by composing <code>Suite</code> style and mixin traits.</li> <li>You define test suites by composing <code>Suite</code> instances.</li> </ul> <p> To include ScalaTest in your sbt project, simply add this line: </p> <pre class="stHighlighted"> libraryDependencies += <span class="stQuotedString">"org.scalatest"</span> %% <span class="stQuotedString">"scalatest"</span> % <span class="stQuotedString">"3.2.19"</span> % <span class="stQuotedString">"test"</span> </pre> <p> To include ScalaTest in your Maven project, use: </p> <pre class="stHighlighted"> <dependency> <groupId>org.scalatest</groupId> <artifactId>scalatest_3</artifactId> <version>3.2.19</version> <scope>test</scope> </dependency> </pre> <p> For other ways to include ScalaTest in your project, see <a href="/user_guide/running_your_tests">Running your tests</a>. </p> <p> Using ScalaTest on your project is as easy as 1, 2, 3: </p> <ol> <li><a href="/user_guide/selecting_a_style">Select your testing styles</a> <li><a href="/user_guide/defining_base_classes">Define your base classes</a> <li><a href="/user_guide/writing_your_first_test">Start writing tests</a> </ol> </td> </tr> </table> </div> <!-- body --> <div style="font-size: 66%; margin-top: 60px"> <p> ScalaTest is brought to you by Bill Venners and Artima.<br /> ScalaTest is free, open-source software released under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0 license</a>. </p> <p> If your company loves ScalaTest, please consider <a href="/sponsor">sponsoring the project</a>. </p> <p> Copyright © 2009-2025 Artima, Inc. All Rights Reserved. </p> <p> <a href="http://www.artima.com" class="no_link_hover"> <img src="/assets/images/artima100Black.png" style="margin-top: 2px" width="100" height="38" alt="artima"/> </a> </p> </div> <!-- style="..." --> </div> <!-- Container --> </body> </html>