class
Tag
extends AnyRef
Instance Constructors
-
new
Tag
(name: String)
Value Members
-
def
!=
(arg0: AnyRef): Boolean
-
def
!=
(arg0: Any): Boolean
-
def
##
(): Int
-
def
==
(arg0: AnyRef): Boolean
-
def
==
(arg0: Any): Boolean
-
def
asInstanceOf
[T0]
: T0
-
def
clone
(): AnyRef
-
def
eq
(arg0: AnyRef): Boolean
-
def
equals
(arg0: Any): Boolean
-
def
finalize
(): Unit
-
def
getClass
(): java.lang.Class[_]
-
def
hashCode
(): Int
-
def
isInstanceOf
[T0]
: Boolean
-
val
name
: String
-
def
ne
(arg0: AnyRef): Boolean
-
def
notify
(): Unit
-
def
notifyAll
(): Unit
-
def
synchronized
[T0]
(arg0: ⇒ T0): T0
-
def
toString
(): String
-
def
wait
(): Unit
-
def
wait
(arg0: Long, arg1: Int): Unit
-
def
wait
(arg0: Long): Unit
Inherited from AnyRef
Inherited from Any
Class whose subclasses can be used to tag tests in style traits in which tests are defined as functions.
ScalaTest has two ways to tag tests: annotations and instances of this
Tag
class. To tag a test method or an entire test class, you use a tag annotation, whereas to tag a test function, you use aTag
object. Though not required, it is usually a good idea to define both an annotation and a correspondingTag
object for each conceptual tag you want, so you can tag anything: test functions, test classes, and test methods. The name of the conceptual tag is the fully qualified name of the annotation interface, so you must pass this name to theTag
constructor.For example, imagine you want to tag integration tests that use the actual database, and are, therefore, generally slower. You could create a tag annotation and object called
DbTest
. To give them both the same simple name, you can declare them in different packages. The tag annotation must be written in Java, not Scala, because annotations written in Scala are not accessible at runtime. Here's an example:Given this annotation's fully qualified name is
com.mycompany.myproject.testing.tags.DbTest
the correspondingTag
object decaration must have that name passed to its constructor, like this:Given these definitions, you could tag a test function as a
DbTest
in, for example, aFlatSpec
like this:You could tag a test method as a
DbTest
in, for example, aSuite
like this:And you could tag all the tests in an entire test class by annotating the class, like this:
In the previous example, both tests will be tagged as
DBTest
s even though the tests are not tagged as such individually.When you run ScalaTest and want to either include or exclude
DbTest
s, you'd give the fully qualified name of the tag annotation (which is also the name passed to the correspondingTag
constructor) toRunner
. For example, here's how you'd excludeDbTest
s on theRunner
command line:For examples of tagging in other style traits, see the "Tagging tests" section in the documentation for the trait:
FeatureSpec
testsFlatSpec
testsFreeSpec
testsFunSpec
testsFunSuite
testsPropSpec
testsSuite
testsWordSpec
tests