org.specs2.matcher
Type members
Classlikes
Inherit this trait to provide a Matcher where both the actual and the expected values can be adapted with a function.
Inherit this trait to provide a Matcher where both the actual and the expected values can be adapted with a function.
This matcher always matches any value of type T
This matcher always matches any value of type T
This trait provides matchers which are applicable to any type of value
This trait provides matchers which are applicable to any type of value
- Companion:
- object
ValueCheck for a typed expected value. It uses the BeEqualTo matcher
ValueCheck for a typed expected value. It uses the BeEqualTo matcher
ValueCheck for an untyped expected value. It uses the BeEqualTo matcher
ValueCheck for an untyped expected value. It uses the BeEqualTo matcher
Matcher for a boolean value which must be true
Matcher for a boolean value which must be true
Matcher for a boolean value which must be true
Matcher for a boolean value which must be true
transient class allowing the creation of a delta
transient class allowing the creation of a delta
This trait provides implicit definitions and types to create DataTables.
This trait provides implicit definitions and types to create DataTables.
A DataTable has a header defining column names and rows holding values. It is possible to apply a function taking the row values and returning a Result.
A TableHeader is defined by separating the column names with '|': "a" | "b" | "c"
A DataRow is defined by separating the row values with '!': 1 ! 2 ! 3
Note that the '!' method can conflict with the creation of Examples when the value is a string. In that case it is possible to use the '!!! method to disambiguate:
"1" !! "2" ! "3"
In that case the first column of the header can also be defined with '||' for pure symmetry reasons:
"a" || "b" | "c"
"1" !! "2" ! "3"
- See also:
org.specs2.matcher.DataTablesSpec for examples
Matchers for the Either datatype
Matchers for the Either datatype
- Companion:
- object
This trait adds the possibility to retry a given matcher until it succeeds.
This trait adds the possibility to retry a given matcher until it succeeds.
This was contributed by @robey (http://robey.lag.net)
- Companion:
- object
These matchers can be used to check if exceptions are thrown or not
These matchers can be used to check if exceptions are thrown or not
- Companion:
- object
The Expectable class models anything which can be checked by applying a Matcher
The Expectable class models anything which can be checked by applying a Matcher
It stores a value which is only evaluated when necessary and an optional additional description for that value.
The Expectable object is responsible for creating its own description, based on the value toString method and and an additional description.
- Companion:
- object
Factory methods for creating Expectables
Factory methods for creating Expectables
- Companion:
- class
This trait provides implicit definitions to transform any value into an Expectable
This trait provides implicit definitions to transform any value into an Expectable
- Companion:
- object
Base trait to create expectations.
Base trait to create expectations.
An expectation is a value which can have an optional description and which can be matched to produce a result (for example against an expected value)
When a result is produced it can possibly be thrown as an exception based on the behaviour of the ResultChecks trait
This trait can be used in conjunction with Pattern matchers:
This trait can be used in conjunction with Pattern matchers:
List(1, 2) must beLike { case List(a, b) => ok } List(1, 2) must beLike { case List(a, b) => ko("unexpected") }
- Companion:
- object
This trait is for transforming matchers of values to matchers of Futures
This trait is for transforming matchers of values to matchers of Futures
- Companion:
- object
this trait allows to fill-in stack traces on match results for precise location
this trait allows to fill-in stack traces on match results for precise location
The Matcher
trait is the base trait for any Matcher.
The Matcher
trait is the base trait for any Matcher.
This trait can be extended to provide an appropriate apply
method that will check an expectable value a: Expectable[T]
.
The result of a match is a Result
Matchers can be composed.
Implementation notes:
-
the parameter to the apply method must be a by-name parameter. This allows some values to be evaluated only when necessary.
-
However in the implementation of the apply function, it must be taken care of not evaluating the parameter twice. Assigning it to a val is the solution to this issue.
- Companion:
- object
This trait adds some implicits to easily fold sequences of results
This trait adds some implicits to easily fold sequences of results
- Companion:
- object
Trait aggregating the most common specs2 matchers
Trait aggregating the most common specs2 matchers
- Companion:
- object
This trait provides implicit definitions to check values with matchers by using a "must" syntax: value must matcher
This trait provides implicit definitions to check values with matchers by using a "must" syntax: value must matcher
- Companion:
- object
This trait provides implicit definitions to transform any value into an Expectable which throws exceptions when a match fails
This trait provides implicit definitions to transform any value into an Expectable which throws exceptions when a match fails
- Companion:
- object
This matcher never matches any value of type T
This matcher never matches any value of type T
this trait doesn't fill-in stack traces
this trait doesn't fill-in stack traces
This trait can be used to cancel the effect of thrown expectations.
This trait can be used to cancel the effect of thrown expectations.
For example it can be mixed-in a mutable.Specification so that no exception is thrown on failure
This trait can be used to suppress the TypedEqual implicit
This trait can be used to suppress the TypedEqual implicit
class representing a numeric range
class representing a numeric range
Those definitions help specifying the result messages for matchers
Those definitions help specifying the result messages for matchers
- Companion:
- object
This kind of expectable can be followed by the verb should to apply a matcher:
This kind of expectable can be followed by the verb should to apply a matcher:
1 should beEqualTo(1)
For convenience, several shouldMatcher methods have also been defined as shortcuts to equivalent:
a should matcher
- Companion:
- object
This trait provides implicit definitions to check values with matchers by using a "should" syntax: value should matcher
This trait provides implicit definitions to check values with matchers by using a "should" syntax: value should matcher
- Companion:
- object
This trait provides implicit definitions to transform any value into an Expectable which throws exceptions when a match fails
This trait provides implicit definitions to transform any value into an Expectable which throws exceptions when a match fails
- Companion:
- object
The StringMatchers
trait provides matchers which are applicable to String objects
The StringMatchers
trait provides matchers which are applicable to String objects
- Companion:
- object
Thrown expectations will throw a FailureException if a match fails
Thrown expectations will throw a FailureException if a match fails
This trait can be extended to be used in another framework like ScalaTest:
trait ScalaTestExpectations extends ThrownExpectations { override protected def checkResultFailure(r: =>Result) = { r match { case f @ Failure(ko, _, _, _) => throw new TestFailedException(f.message, f.exception, 0) case _ => () } m } }
- Companion:
- object
Lightweight ThrownExpectations trait with less implicit methods
Lightweight ThrownExpectations trait with less implicit methods
This trait can be used to integrate failures and skip messages into specs2
This trait can be used to integrate failures and skip messages into specs2
This trait adds some implicits to create expectations with the ===
sign
This trait adds some implicits to create expectations with the ===
sign
- Companion:
- object
Common interface for checks of a value of type T:
Common interface for checks of a value of type T:
- a expected single value of type T
- a Matcher[T]
- a function returning a type R having an AsResult instance
- Companion:
- object
implicit conversions used to create ValueChecks
implicit conversions used to create ValueChecks
- Companion:
- object
Value members
Inherited methods
this method can be overridden to throw exceptions when checking a result
this method can be overridden to throw exceptions when checking a result
- Inherited from:
- ResultChecks
this method can be overridden to intercept a Result and modify it. It is used for example to set a stacktrace providing the location of a failure
this method can be overridden to intercept a Result and modify it. It is used for example to set a stacktrace providing the location of a failure
- Inherited from:
- ResultChecks
this method can be overridden to avoid filling-in a stacktrace indicating the location of the result
this method can be overridden to avoid filling-in a stacktrace indicating the location of the result
- Inherited from:
- MatchResultStackTrace