ScalaTest 1.0

This document is the API specification for ScalaTest 1.0

Class Summary
trait BeMatcher [-T] extends (T) => MatchResult
Trait extended by matcher objects, which may appear after the word be, that can match a value of the specified type. The value to match is passed to the BeMatcher's apply method. The result is a MatchResult. A BeMatcher is, therefore, a function from the specified type, T, to a MatchResult.
case final class BePropertyMatchResult (val matches : Boolean, val propertyName : java.lang.String) extends scala.Product
The result of a Boolean property match operation, such as one performed by a BePropertyMatcher, which contains one field that indicates whether the match succeeded (i.e., the Boolean property was true) and one field that provides the name of the property.
trait BePropertyMatcher [-T] extends (T) => BePropertyMatchResult
Trait extended by matcher objects, which may appear after the word be, that can match against a Boolean property. The match will succeed if and only if the Boolean property equals true. The object containing the property, which must be of the type specified by the BePropertyMatcher's type parameter T, is passed to the BePropertyMatcher's apply method. The result is a BePropertyMatchResult. A BePropertyMatcher is, therefore, a function from the specified type, T, to a BePropertyMatchResult.
case final class HavePropertyMatchResult [P](val matches : Boolean, val propertyName : java.lang.String, val expectedValue : P, val actualValue : P) extends scala.Product
The result of a property match operation such as one performed by a HavePropertyMatcher, which contains one field that indicates whether the match succeeded (i.e., the property had its expected value), one field that provides the name of the property, and two fields giving the expected and actual values. HavePropertyMatchResult's type parameter, P, specifies the type of the property.
trait HavePropertyMatcher [-T, P] extends (T) => HavePropertyMatchResult[P]
Trait extended by matcher objects, which may appear after the word have, that can match against a property of the type specified by the HavePropertyMatcher's second type parameter P. HavePropertyMatcher's first type parameter, T, specifies the type that declares the property. The match will succeed if and only if the value of the property equals the specified value. The object containing the property is passed to the HavePropertyMatcher's apply method. The result is a HavePropertyMatchResult[P]. A HavePropertyMatcher is, therefore, a function from the specified type, T, to a HavePropertyMatchResult[P].
case final class MatchResult (val matches : Boolean, val failureMessage : java.lang.String, val negatedFailureMessage : java.lang.String, val midSentenceFailureMessage : java.lang.String, val midSentenceNegatedFailureMessage : java.lang.String) extends scala.Product
The result of a match operation, such as one performed by a Matcher or BeMatcher, which contains one field that indicates whether the match succeeded and four fields that provide failure messages to report under different circumstances.
trait Matcher [-T] extends (T) => MatchResult
Trait extended by objects that can match a value of the specified type. The value to match is passed to the matcher's apply method. The result is a MatchResult. A matcher is, therefore, a function from the specified type, T, to a MatchResult.
trait Matchers extends Assertions
This trait is part of the ScalaTest matchers DSL. Please see the documentation for ShouldMatchers or MustMatchers for an overview of the matchers DSL.
trait MustMatchers extends Matchers with MustVerb
Trait that provides a domain specific language (DSL) for expressing assertions in tests using the word must. (If you prefer the word should, you can alternatively mix in trait ShouldMatchers.) For example, if you mix MustMatchers into a suite class, you can write an equality assertion in that suite like this:
 object must equal (3)
 
trait ShouldMatchers extends Matchers with ShouldVerb
Trait that provides a domain specific language (DSL) for expressing assertions in tests using the word should. (If you prefer the word must, you can alternatively mix in trait MustMatchers.) For example, if you mix ShouldMatchers into a suite class, you can write an equality assertion in that suite like this:
 object should equal (3)
 
Object Summary
object BePropertyMatchResult extends AnyRef
Companion object for the BePropertyMatchResult case class.
object HavePropertyMatchResult extends AnyRef
Companion object for the HavePropertyMatchResult case class.
object MatchResult extends AnyRef
Companion object for the MatchResult case class.
object MustMatchers extends MustMatchers
Companion object that facilitates the importing of MustMatchers members as an alternative to mixing it the trait. One use case is to import MustMatchers members so you can use them in the Scala interpreter:
 $scala -classpath scalatest.jar
 Welcome to Scala version 2.7.3.final (Java HotSpot(TM) Client VM, Java 1.5.0_16).
 Type in expressions to have them evaluated.
 Type :help for more information.
 
 scala> import org.scalatest.matchers.MustMatchers._
 import org.scalatest.matchers.MustMatchers._
 
 scala> 1 must equal (2)
 org.scalatest.TestFailedException: 1 did not equal 2
 	at org.scalatest.matchers.Helper$.newTestFailedException(Matchers.scala:40)
 	at org.scalatest.matchers.MustMatchers$MustMethodHelper$.mustMatcher(MustMatchers.scala:826)
 	at org.scalatest.matchers.MustMatchers$IntMustWrapper.must(MustMatchers.scala:1123)
 	at .(:9)
 	at .()
 	at RequestR...

 scala> "hello, world" must startWith ("hello")
 
 scala> 7 must (be >= (3) and not be <= (7))
 org.scalatest.TestFailedException: 7 was greater than or equal to 3, but 7 was less than or equal to 7
 	at org.scalatest.matchers.Helper$.newTestFailedException(Matchers.scala:40)
 	at org.scalatest.matchers.MustMatchers$MustMethodHelper$.mustMatcher(MustMatchers.scala:826)
 	at org.scalatest.matchers.MustMatchers$IntMustWrapper.must(MustMatchers.scala:1123)
 	at .(...
 
object ShouldMatchers extends ShouldMatchers
Companion object that facilitates the importing of ShouldMatchers members as an alternative to mixing it the trait. One use case is to import ShouldMatchers members so you can use them in the Scala interpreter:
 $scala -classpath scalatest.jar
 Welcome to Scala version 2.7.3.final (Java HotSpot(TM) Client VM, Java 1.5.0_16).
 Type in expressions to have them evaluated.
 Type :help for more information.
 
 scala> import org.scalatest.matchers.ShouldMatchers._
 import org.scalatest.matchers.ShouldMatchers._
 
 scala> 1 should equal (2)
 org.scalatest.TestFailedException: 1 did not equal 2
 	at org.scalatest.matchers.Helper$.newTestFailedException(Matchers.scala:40)
 	at org.scalatest.matchers.ShouldMatchers$ShouldMethodHelper$.shouldMatcher(ShouldMatchers.scala:826)
 	at org.scalatest.matchers.ShouldMatchers$IntShouldWrapper.should(ShouldMatchers.scala:1123)
 	at .(:9)
 	at .()
 	at RequestR...

 scala> "hello, world" should startWith ("hello")
 
 scala> 7 should (be >= (3) and not be <= (7))
 org.scalatest.TestFailedException: 7 was greater than or equal to 3, but 7 was less than or equal to 7
 	at org.scalatest.matchers.Helper$.newTestFailedException(Matchers.scala:40)
 	at org.scalatest.matchers.ShouldMatchers$ShouldMethodHelper$.shouldMatcher(ShouldMatchers.scala:826)
 	at org.scalatest.matchers.ShouldMatchers$IntShouldWrapper.should(ShouldMatchers.scala:1123)
 	at .(...