ScalaTest User Guide Getting started Selecting testing styles Defining base classes Writing your first test Using assertions Tagging your tests Running your tests Sharing fixtures Sharing tests Using matchers Testing with mock objects Property-based testing Asynchronous testing Using Scala-js Using Inside Using OptionValues Using EitherValues Using PartialFunctionValues Using PrivateMethodTester Using WrapWith Philosophy and design Migrating to 3.0 |
Tagging your testsScalaTest allows you to define arbitrary test categories, to "tag" tests as belonging to those categories, and filter tests to run based on their tags. For example, you could tag some tests as being slow and chose to exclude the slow tests during some runs. ScalaTest supports one tag by default: ignore. You can tag a test as ignored to "switch it off" temporarily. Tagging tests as ignored
To support the common use case of “temporarily” disabling a test, with the
good intention of resurrecting the test at a later time, each style trait provides a way to tag tests as ignored.
For example, in a import org.scalatest.flatspec.AnyFlatSpec import scala.collection.mutable.Stack
If you run this version of scala> (new StackSpec).execute() It will run only the first test and report that the second test was ignored: A Stack - should pop values in last-in-first-out order - should throw NoSuchElementException if an empty stack is popped !!! IGNORED !!! Defining and using your own tags
Each style trait provides a way to tag tests. To tag tests in a import org.scalatest.Tag
Given this definitions, you could tag import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.tagobjects.Slow This code marks both tests with the When executing a suite, tests can optionally be included and/or excluded (i.e., filtered) based on their tags. Here's how: Next, learn about running your tests. |
ScalaTest is brought to you by Bill Venners and Artima.
ScalaTest is free, open-source software
released under the Apache
2.0 license.
If your company loves ScalaTest, please consider sponsoring the project.
Copyright © 2009-2025 Artima, Inc. All Rights Reserved.