trait Matcher[-T] extends AnyRef
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 MatchResult object (@see MatchResult).
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.
- Self Type
- Matcher[T]
- Alphabetic
- By Inheritance
- Matcher
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
apply[S <: T](t: Expectable[S]): MatchResult[S]
apply this matcher to an Expectable
apply this matcher to an Expectable
- returns
a MatchResult describing the outcome of the match
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
^^[S](f: (S) ⇒ Expectable[T], dummy: Int = 0): Matcher[S]
Adapt a matcher to another.
Adapt a matcher to another. ex:
be_==("message") ^^ (_.getMessage aka "trimmed")
can be applied to an exception
The dummy value is used to help to disambiguate with the overloaded ^^ function
-
def
^^[S](f: (S) ⇒ T): Matcher[S]
Adapt a matcher to another.
Adapt a matcher to another. ex:
be_==("message") ^^ (_.getMessage)
can be applied to an exception
-
def
and[S <: T](m: ⇒ Matcher[S]): Matcher[S]
the logical and between 2 matchers
the logical and between 2 matchers
- See also
MatchResult.and
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
eventually(retries: Int, sleep: (Int) ⇒ Duration): Matcher[T]
- sleep
the function applied on the retry number (first is 1)
- returns
a matcher that needs to eventually match, after a given number of retries and a sleep time
aResult mustEqual(expected).eventually(retries = 2, _ * 100.milliseconds)
-
def
eventually(retries: Int, sleep: Duration): Matcher[T]
- returns
a matcher that needs to eventually match, after a given number of retries and a sleep time
-
def
eventually: Matcher[T]
- returns
a matcher that needs to eventually match, after 40 retries and a sleep time of 100 milliseconds
-
def
failure[S <: T](message: ⇒ String, value: Expectable[S]): MatchResult[S]
This method can be used to create a failed match result
This method can be used to create a failed match result
- Attributes
- protected
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
iff(b: Boolean): Matcher[T]
when the condition is true the matcher is applied, when it's false, the matcher must fail
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
lazily: Matcher[() ⇒ T]
The
lazily
operator returns a Matcher which will match a function returning the expected value -
def
mute: Matcher[T]
- returns
a Matcher with no messages
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
not: Matcher[T]
negate a Matcher
negate a Matcher
- See also
MatchResult.not
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
or[S <: T](m: ⇒ Matcher[S]): Matcher[S]
the logical or between 2 matchers
the logical or between 2 matchers
- See also
MatchResult.or
-
def
orPending(message: (String) ⇒ String): Matcher[T]
- returns
a Pending MatchResult if this matcher fails, modifying the failure message with a pending message.
-
def
orPending(m: String): Matcher[T]
- returns
a Pending MatchResult if this matcher fails, prefixing the failure message with a pending message. If the pending message is empty, only the failure message is printed
-
def
orPending: Matcher[T]
- returns
a Pending MatchResult if this matcher fails
-
def
orSkip(message: (String) ⇒ String): Matcher[T]
- returns
a Skip MatchResult if this matcher fails, modifying the failure message with a skip message.
-
def
orSkip(m: String): Matcher[T]
- returns
a Skip MatchResult if this matcher fails, prefixing the failure message with a skip message. If the skip message is empty, only the failure message is printed
-
def
orSkip: Matcher[T]
- returns
a Skip MatchResult if this matcher fails
-
def
result[S <: T](other: MatchResultMessages.MatchResultMessage, value: Expectable[S]): MatchResult[S]
- returns
a MatchResult using the messages embedded in a MatchResultMessage (i.e. an accumulation of messages from other matches)
- Attributes
- protected
-
def
result[S <: T](other: Result, value: Expectable[S]): MatchResult[S]
- returns
a Match Result from another result
- Attributes
- protected
-
def
result[S <: T](other: MatchResult[_], value: Expectable[S]): MatchResult[S]
- returns
a MatchResult copied on another one, but with a different expectable
- Attributes
- protected
-
def
result[S <: T](test: ⇒ Boolean, okMessage: ⇒ String, koMessage: ⇒ String, value: Expectable[S], details: Details): MatchResult[S]
- returns
a MatchResult with an okMessage, a koMessage, the expectable value and details about the failure if any
- Attributes
- protected
-
def
result[S <: T](test: ⇒ Boolean, okMessage: ⇒ String, koMessage: ⇒ String, value: Expectable[S], expected: String, actual: String): MatchResult[S]
- returns
a MatchResult with an okMessage, a koMessage, the expectable value and the expected/actual values as string to display a failure comparison if necessary
- Attributes
- protected
-
def
result[S <: T](triplet: ⇒ (Boolean, String, String), value: Expectable[S]): MatchResult[S]
- returns
a MatchResult with an okMessage, a koMessage and the expectable value
- Attributes
- protected
-
def
result[S <: T](test: ⇒ Boolean, okMessage: ⇒ String, koMessage: ⇒ String, value: Expectable[S]): MatchResult[S]
- returns
a MatchResult with an okMessage, a koMessage and the expectable value
- Attributes
- protected
-
def
setMessage(message: String): Matcher[T]
- returns
set a new failure message of a matcher
-
def
success[S <: T](message: ⇒ String, value: Expectable[S]): MatchResult[S]
This method can be used to create a successful match result
This method can be used to create a successful match result
- Attributes
- protected
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
test: (T) ⇒ Boolean
- returns
a test function corresponding to this matcher
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
unless(b: Boolean, m: String = ""): Matcher[T]
only apply this matcher if the condition is false
-
def
updateMessage(f: (String) ⇒ String): Matcher[T]
- returns
update the failure message of a matcher
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
when(b: Boolean, m: String = ""): Matcher[T]
only apply this matcher if the condition is true