|
ScalaTest User Guide Writing your first test Using assertions Tagging your tests Running your tests Sharing fixtures Sharing tests Using matchers Testing with mock objects Tests as specifications Property-based testing Using Selenium Other goodies Philosophy and design Selecting testing styles |
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 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 these definitions, you could tag import org.scalatest.FlatSpec 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, with
contributions from several other folks. It is sponsored by
Artima, Inc.
ScalaTest is free, open-source software
released under the Apache
2.0 license.
Copyright © 2009-2012 Artima, Inc. All Rights Reserved.