Typeclass that enables for aggregations certain contain
syntax in the ScalaTest matchers DSL.
Supertrait for CheckerAsserting
typeclasses, which are used to implement and determine the result
type of GeneratorDrivenPropertyChecks's apply
and forAll
method.
Supertrait for CheckerAsserting
typeclasses, which are used to implement and determine the result
type of GeneratorDrivenPropertyChecks's apply
and forAll
method.
Currently, an GeneratorDrivenPropertyChecks expression will have result type Assertion
, if the function passed has result type Assertion
,
else it will have result type Unit
.
Supertrait for typeclasses that enable loneElement
and inspectors syntax
for collections.
Supertrait for typeclasses that enable loneElement
and inspectors syntax
for collections.
A Collecting[E, C]
provides access to the "collecting nature" of type C
in such
a way that loneElement
syntax can be used with type C
. A C
can be any type of "collecting", a type that in some way collects or brings together elements of type E
.
ScalaTest provides implicit implementations for several types. You can enable the contain
matcher syntax
on your own type U
by defining an Collecting[E, U]
for the type and making it available implicitly.
ScalaTest provides implicit Collecting
instances for scala.collection.GenTraversable
,
Array
, java.util.Collection
and java.util.Map
in the
Collecting
companion object.
Supertrait for typeclasses that enable certain contain
matcher syntax for containers.
Supertrait for typeclasses that enable certain contain
matcher syntax for containers.
A Containing[C]
provides access to the "containing nature" of type C
in such
a way that relevant contain
matcher syntax can be used with type C
. A C
can be any type of "container," a type that in some way can contains one or more other objects. ScalaTest provides
implicit implementations for several types. You can enable the contain
matcher syntax on your own
type U
by defining an Containing[U]
for the type and making it available implicitly.
ScalaTest provides implicit Containing
instances for scala.collection.GenTraversable
,
java.util.Collection
, java.util.Map
, String
, Array
,
and scala.Option
in the Containing
companion object.
Containing
versus Aggregating
The difference between Containing
and Aggregating
is that
Containing
enables contain
matcher syntax that makes sense for "box" types that can
contain at most one value (for example, scala.Option
),
whereas Aggregating
enables contain
matcher syntax for full-blown collections and other
aggregations of potentially more than one object. For example, it makes sense to make assertions like these, which
are enabled by Containing
, for scala.Option
:
val option: Option[Int] = Some(7) option should contain (7) option should contain oneOf (6, 7, 8) option should contain noneOf (3, 4, 5)
However, given a scala.Option
can only ever contain at most one object, it doesn't make
sense to make assertions like the following, which are enabled via Aggregation
:
// Could never succeed, so does not compile option should contain allOf (6, 7, 8)
The above assertion could never succceed, because an option cannot contain more than
one value. By default the above statement does not compile, because contain
allOf
is enabled by Aggregating
, and ScalaTest provides no implicit Aggregating
instance
for type scala.Option
.
Supertrait for typeclasses that enable the be defined
matcher syntax.
Supertrait for typeclasses that enable the be defined
matcher syntax.
A Definition[T]
provides access to the "definition nature" of type S
in such
a way that be defined
matcher syntax can be used with type T
. A T
can be any type for which the concept of being defined makes sense, such as scala.Option
. ScalaTest provides
implicit implementation for scala.Option
. You can enable the be defined
matcher syntax on your own
type U
by defining a Definition[U]
for the type and making it available implicitly.
ScalaTest provides an implicit Definition
instance for scala.Option
,
arbitary object with isDefined()
or isDefined
in the Definition
companion object.
Supertrait for typeclasses that enable be empty
matcher syntax.
Supertrait for typeclasses that enable be empty
matcher syntax.
An Emptiness[T]
provides access to the "emptiness" of type T
in such
a way that be empty
matcher syntax can be used with type T
. A T
can be any type that in some way can be empty. ScalaTest provides implicit implementations for several types.
You can enable the be empty
matcher syntax on your own type U
by defining an Emptiness[U]
for the type and making it available implicitly.
ScalaTest provides implicit Emptiness
instances for scala.collection.GenTraversable
,
java.util.Collection
, java.util.Map
, String
, Array
,
and scala.Option
in the Emptiness
companion object.
Supertrait for typeclasses that enable the exist
matcher syntax.
Supertrait for typeclasses that enable the exist
matcher syntax.
An Existence[S]
provides access to the "existence nature" of type S
in such
a way that exist
matcher syntax can be used with type S
. A S
can be any type for which the concept of existence makes sense, such as java.io.File
. ScalaTest provides
implicit implementations for java.io.File
. You can enable the exist
matcher syntax on your own
type U
by defining a Existence[U]
for the type and making it available implicitly.
ScalaTest provides an implicit Existence
instance for java.io.File
in the Existence
companion object.
Supertrait for Futureistic
typeclasses.
Supertrait for Futureistic
typeclasses.
Trait Futureistic
is a typeclass trait for objects that can be used with
the complete
-lastly
syntax of trait
CompleteLastly
.
Supertrait for InspectorAsserting
typeclasses, which are used to implement and determine the result
type of Inspectors
methods such as forAll
, forBetween
, etc.
Supertrait for InspectorAsserting
typeclasses, which are used to implement and determine the result
type of Inspectors
methods such as forAll
, forBetween
, etc.
Currently, an inspector expression will have result type Assertion
, if the function passed has result type Assertion
,
else it will have result type Unit
.
Supertrait for typeclasses that enable contain key
matcher syntax.
Supertrait for typeclasses that enable contain key
matcher syntax.
A KeyMapping[M]
provides access to the "key mapping nature" of type M
in such
a way that contain key
matcher syntax can be used with type M
. A M
can be any type for which contain key
syntax makes sense. ScalaTest provides implicit implementations
for scala.collection.GenMap
and java.util.Map
. You can enable the contain key
matcher syntax on your own type U
by defining a KeyMapping[U]
for the type and making it
available implicitly.
ScalaTest provides implicit KeyMapping
instances for scala.collection.GenMap
,
and java.util.Map
in the KeyMapping
companion object.
Supertrait for Length
typeclasses.
Supertrait for Length
typeclasses.
Trait Length
is a typeclass trait for objects that can be queried for length.
Objects of type T for which an implicit Length[T]
is available can be used
with the should have length
syntax.
In other words, this trait enables you to use the length checking
syntax with arbitrary objects. As an example, the following Bridge
class:
scala> import org.scalatest._ import org.scalatest._ scala> import enablers.Length import enablers.Length scala> import Matchers._ import Matchers._ scala> case class Bridge(span: Int) defined class Bridge
Out of the box you can't use the should have length
syntax with Bridge
,
because ScalaTest doesn't know that a bridge's span means its length:
scala> val bridge = new Bridge(2000) bridge: Bridge = Bridge(2000) scala> bridge should have length 2000 <console>:34: error: could not find implicit value for parameter len: org.scalatest.enablers.Length[Bridge] bridge should have length 2000 ^
You can teach this to ScalaTest, however, by defining an implicit Length[Bridge]
.
scala> implicit val lengthOfBridge: Length[Bridge] = | new Length[Bridge] { | def lengthOf(b: Bridge): Long = b.span | } lengthOfBridge: org.scalatest.enablers.Length[Bridge] = $anon$1@3fa27a4a
With the implicit Length[Bridge]
in scope, you can now use ScalaTest's should have length
syntax with Bridge
instances:
scala> bridge should have length 2000 res4: org.scalatest.Assertion = Succeeded scala> bridge should have length 2001 org.scalatest.exceptions.TestFailedException: Bridge(2000) had length 2000 instead of expected length 2001 at org.scalatest.MatchersHelper$.newTestFailedException(MatchersHelper.scala:148) at org.scalatest.MatchersHelper$.indicateFailure(MatchersHelper.scala:366) at org.scalatest.Matchers$ResultOfHaveWordForExtent.length(Matchers.scala:2720) ... 43 elided
Supertrait for Messaging
typeclasses.
Supertrait for Messaging
typeclasses.
Trait Messaging
is a typeclass trait for objects that can be queried for message.
Objects of type T for which an implicit Messaging[T]
is available can be used
with the should have message
syntax.
You can enable the have message
matcher syntax on your own
type U
by defining a Messaging[U]
for the type and making it available implicitly.
ScalaTest provides an implicit Messaging
instance for java.lang.Throwable
and
arbitary object with message()
, message
, getMessage()
or getMessage
method in the Messaging
companion object.
Supertrait for typeclasses that enable the be readable
matcher syntax.
Supertrait for typeclasses that enable the be readable
matcher syntax.
A Readability[T]
provides access to the "readable nature" of type T
in such
a way that be readable
matcher syntax can be used with type T
. A T
can be any type for which the concept of being readable makes sense, such as java.io.File
.
You can enable the be readable
matcher syntax on your own type U
by defining a
Readability[U]
for the type and making it available implicitly.
ScalaTest provides an implicit Readability
instance for java.io.File
and arbitary
object with isReadable()
or isReadable
in the Readability
companion object.
Typeclass that enables for sequencing certain contain
syntax in the ScalaTest matchers DSL.
Typeclass that enables for sequencing certain contain
syntax in the ScalaTest matchers DSL.
An Sequencing[A]
provides access to the "sequenching nature" of type A
in such
a way that relevant contain
matcher syntax can be used with type A
. An A
can be any type of sequencing—an object that in some way brings together other objects in order.
ScalaTest provides implicit implementations for several types out of the box in the
Sequencing
companion object:
scala.collection.GenSeq
scala.collection.SortedSet
scala.collection.SortedMap
Array
java.util.List
java.util.SortedSet
java.util.SortedMap
String
The contain
syntax enabled by this trait is:
result should contain inOrder (1, 2, 3)
result should contain inOrderOnly (1, 2, 3)
result should contain theSameElementsInOrderAs List(1, 2, 3)
You can enable the contain
matcher syntax enabled by Sequencing
on your own
type U
by defining an Sequencing[U]
for the type and making it available implicitly.
Supertrait for Size
typeclasses.
Supertrait for Size
typeclasses.
Trait Size
is a typeclass trait for objects that can be queried for size.
Objects of type T for which an implicit Size[T]
is available can be used
with the should have size
syntax.
In other words, this trait enables you to use the size checking
syntax with arbitrary objects. As an example, the following Bridge
class:
scala> import org.scalatest._ import org.scalatest._ scala> import enablers.Size import enablers.Size scala> import Matchers._ import Matchers._ scala> case class Bridge(span: Int) defined class Bridge
Out of the box you can't use the should have size
syntax with Bridge
,
because ScalaTest doesn't know that a bridge's span means its size:
scala> val bridge = new Bridge(2000) bridge: Bridge = Bridge(2000) scala> bridge should have size 2000 <console>:34: error: could not find implicit value for parameter sz: org.scalatest.enablers.Size[Bridge] bridge should have size 2000 ^
You can teach this to ScalaTest, however, by defining an implicit Size[Bridge]
.
scala> implicit val sizeOfBridge: Size[Bridge] = | new Size[Bridge] { | def sizeOf(b: Bridge): Long = b.span | } sizeOfBridge: org.scalatest.enablers.Size[Bridge] = $anon$1@3fa27a4a
With the implicit Size[Bridge]
in scope, you can now use ScalaTest's should have size
syntax with Bridge
instances:
scala> bridge should have size 2000 res4: org.scalatest.Assertion = Succeeded scala> bridge should have size 2001 org.scalatest.exceptions.TestFailedException: Bridge(2000) had size 2000 instead of expected size 2001 at org.scalatest.MatchersHelper$.newTestFailedException(MatchersHelper.scala:148) at org.scalatest.MatchersHelper$.indicateFailure(MatchersHelper.scala:366) at org.scalatest.Matchers$ResultOfHaveWordForExtent.size(Matchers.scala:2720) ... 43 elided
Supertrait for typeclasses that enable the be
sorted
matcher syntax.
Supertrait for typeclasses that enable the be
sorted
matcher syntax.
A Sortable[S]
provides access to the "sortable nature" of type S
in such
a way that be
sorted
matcher syntax can be used with type S
. An S
can be any type for which the concept of being sorted makes sense, such as sequences. ScalaTest provides
implicit implementations for several types. You can enable the be
sorted
matcher syntax on your own
type U
by defining a Sortable[U]
for the type and making it available implicitly.
ScalaTest provides an implicit Sortable
instance for types out of the box
in the Sortable
companion object:
scala.collection.GenSeq
Array
java.util.List
Supertrait for TableAsserting
typeclasses, which are used to implement and determine the result
type of TableDrivenPropertyChecks's forAll
, forEvery
and exists
method.
Supertrait for TableAsserting
typeclasses, which are used to implement and determine the result
type of TableDrivenPropertyChecks's forAll
, forEvery
and exists
method.
Currently, an TableDrivenPropertyChecks expression will have result type Assertion
, if the function passed has result type Assertion
,
else it will have result type Unit
.
Trait that provides a timeoutAfter
construct, which allows you to specify a timeout for an
operation passed as a by-name parameter, as well as a way to signal/interrupt it if the operation exceeds its time limit.
Trait that provides a timeoutAfter
construct, which allows you to specify a timeout for an
operation passed as a by-name parameter, as well as a way to signal/interrupt it if the operation exceeds its time limit.
Class holding lowest priority CheckerAsserting
implicit, which enables GeneratorDrivenPropertyChecks expressions that have result type Unit
.
Class holding lowest priority CheckerAsserting
implicit, which enables GeneratorDrivenPropertyChecks expressions that have result type Unit
.
Class holding lowest priority InspectorAsserting
implicit, which enables inspector expressions that have result type Unit
.
Class holding lowest priority InspectorAsserting
implicit, which enables inspector expressions that have result type Unit
.
Class holding lowest priority TableAsserting
implicit, which enables TableDrivenPropertyChecks expressions that have result type Unit
.
Class holding lowest priority TableAsserting
implicit, which enables TableDrivenPropertyChecks expressions that have result type Unit
.
Class holding lowest priority WheneverAsserting
implicit, which enables Whenever expressions that have result type Unit
.
Class holding lowest priority WheneverAsserting
implicit, which enables Whenever expressions that have result type Unit
.
Supertrait for typeclasses that enable contain value
matcher syntax.
Supertrait for typeclasses that enable contain value
matcher syntax.
A ValueMapping[M]
provides access to the "value mapping nature" of type M
in such
a way that contain
value
matcher syntax can be used with type M
. An M
can be any type for which contain
value
syntax makes sense. ScalaTest provides implicit implementations
for scala.collection.GenMap
and java.util.Map
. You can enable the contain
value
matcher syntax on your own type U
by defining a ValueMapping[U]
for the type and making it
available implicitly.
ScalaTest provides implicit ValueMapping
instances for scala.collection.GenMap
,
and java.util.Map
in the ValueMapping
companion object.
Supertrait for WheneverAsserting
typeclasses, which are used to implement and determine the result
type of Whenever's whenever
method.
Supertrait for typeclasses that enable the be
writable
matcher syntax.
Supertrait for typeclasses that enable the be
writable
matcher syntax.
A Writability[T]
provides access to the "writable nature" of type T
in such
a way that be
writable
matcher syntax can be used with type T
. A T
can be any type for which the concept of being writable makes sense, such as java.io.File
. ScalaTest provides
implicit implementation for java.io.File
. You can enable the be
writable
matcher syntax on your own
type U
by defining a Writability[U]
for the type and making it available implicitly.
ScalaTest provides an implicit Writability
instance for java.io.File
and arbitary
object with isWritable()
or isWritable
in the Writability
companion object.
Companion object for Aggregating
that provides implicit implementations for the following types:
Companion object for Aggregating
that provides implicit implementations for the following types:
scala.collection.GenTraversable
String
Array
java.util.Collection
java.util.Map
Companion object to CheckerAsserting
that provides two implicit providers, a higher priority one for passed functions that have result
type Assertion
, which also yields result type Assertion
, and one for any other type, which yields result type Unit
.
Companion object to CheckerAsserting
that provides two implicit providers, a higher priority one for passed functions that have result
type Assertion
, which also yields result type Assertion
, and one for any other type, which yields result type Unit
.
Companion object for Collecting
that provides implicit implementations for the following types:
Companion object for Collecting
that provides implicit implementations for the following types:
scala.collection.GenTraversable
Array
java.util.Collection
java.util.Map
Companion object for Containing
that provides implicit implementations for the following types:
Companion object for Containing
that provides implicit implementations for the following types:
scala.collection.GenTraversable
String
Array
scala.Option
java.util.Collection
java.util.Map
Companion object for Definition
that provides implicit implementations for the following types:
Companion object for Definition
that provides implicit implementations for the following types:
scala.Option
isDefined()
method that returns Boolean
isDefined
method that returns Boolean
Companion object for Emptiness
that provides implicit implementations for the following types:
Companion object for Emptiness
that provides implicit implementations for the following types:
scala.collection.GenTraversable
String
Array
scala.Option
java.util.Collection
java.util.Map
isEmpty()
method that returns Boolean
isEmpty
method that returns Boolean
Companion object for Existence
that provides implicit implementations for java.io.File
.
Companion object for Existence
that provides implicit implementations for java.io.File
.
Companion object for trait Futuristic
that contains implicit Futuristic
providers for
FutureOutcome
and Future[T]
for any type T
.
Companion object for trait Futuristic
that contains implicit Futuristic
providers for
FutureOutcome
and Future[T]
for any type T
.
Companion object to InspectorAsserting
that provides two implicit providers, a higher priority one for passed functions that have result
type Assertion
, which also yields result type Assertion
, and one for any other type, which yields result type Unit
.
Companion object to InspectorAsserting
that provides two implicit providers, a higher priority one for passed functions that have result
type Assertion
, which also yields result type Assertion
, and one for any other type, which yields result type Unit
.
Companion object for KeyMapping
that provides implicit implementations for scala.collection.GenMap
and java.util.Map
.
Companion object for KeyMapping
that provides implicit implementations for scala.collection.GenMap
and java.util.Map
.
Companion object for Length
that provides implicit implementations for the following types:
Companion object for Length
that provides implicit implementations for the following types:
scala.collection.GenSeq
String
Array
java.util.Collection
length()
method that returns Int
length
method that returns Int
getLength()
method that returns Int
getLength
method that returns Int
length()
method that returns Long
length
method that returns Long
getLength()
method that returns Long
getLength
method that returns Long
Companion object for Messaging
that provides implicit implementations for the following types:
Companion object for Messaging
that provides implicit implementations for the following types:
java.lang.Throwable
message()
method that returns String
message
method that returns String
getMessage()
method that returns String
getMessage
method that returns String
Companion object for Readability
that provides implicit implementations for the following types:
Companion object for Readability
that provides implicit implementations for the following types:
java.io.File
isReadable()
method that returns Boolean
isReadable
method that returns Boolean
Companion object for Sequencing
that provides implicit implementations for the following types:
Companion object for Sequencing
that provides implicit implementations for the following types:
scala.collection.GenSeq
scala.collection.SortedSet
scala.collection.SortedMap
Array
java.util.List
java.util.SortedSet
java.util.SortedMap
String
Companion object for Size
that provides implicit implementations for the following types:
Companion object for Size
that provides implicit implementations for the following types:
scala.collection.GenTraversable
String
Array
java.util.Collection
java.util.Map
size()
method that returns Int
size
method that returns Int
getSize()
method that returns Int
getSize
method that returns Int
size()
method that returns Long
size
method that returns Long
getSize()
method that returns Long
getSize
method that returns Long
Companion object for Sortable
that provides implicit implementations for the following types:
Companion object for Sortable
that provides implicit implementations for the following types:
scala.collection.GenSeq
Array
java.util.List
Companion object to TableAsserting
that provides two implicit providers, a higher priority one for passed functions that have result
type Assertion
, which also yields result type Assertion
, and one for any other type, which yields result type Unit
.
Companion object to TableAsserting
that provides two implicit providers, a higher priority one for passed functions that have result
type Assertion
, which also yields result type Assertion
, and one for any other type, which yields result type Unit
.
Companion object for Timed
typeclass that offers three implicit providers: one for FutureOutcome
,
one for Future
of any type, and one for any other type.
Companion object for Timed
typeclass that offers three implicit providers: one for FutureOutcome
,
one for Future
of any type, and one for any other type.
The details are in the documentation for the implicit providers themselves (methods timed
, timedFutureOf
,
and timedFutureOutcome
), but in short if a time limit is exceeded:
T
in Timed[T]
is FutureOutcome
the FutureOutcome
returned by timeoutAfter
will result in either Failed
or Canceled
Future[U]
, the Future[U]
returned by timeoutAfter
will fail with either a
TestFailedDueToTimeoutException
or a TestCanceledException
.timeoutAfter
method will itself complete abruptly with either TestFailedDueToTimeoutException
or TestCanceledException.
Companion object for ValueMapping
that provides implicit implementations for scala.collection.GenMap
and java.util.Map
.
Companion object for ValueMapping
that provides implicit implementations for scala.collection.GenMap
and java.util.Map
.
Companion object to WheneverAsserting
that provides two implicit providers, a higher priority one for passed functions that have result
type Assertion
, which also yields result type Assertion
, and one for any other type, which yields result type Unit
.
Companion object to WheneverAsserting
that provides two implicit providers, a higher priority one for passed functions that have result
type Assertion
, which also yields result type Assertion
, and one for any other type, which yields result type Unit
.
Companion object for Writability
that provides implicit implementations for the following types:
Companion object for Writability
that provides implicit implementations for the following types:
java.io.File
isWritable()
method that returns Boolean
isWritable
method that returns Boolean
Typeclass that enables for aggregations certain
contain
syntax in the ScalaTest matchers DSL.An
Aggregating[A]
provides access to the "aggregating nature" of typeA
in such a way that relevantcontain
matcher syntax can be used with typeA
. AnA
can be any type of aggregation—an object that in some way aggregates or brings together other objects. ScalaTest provides implicit implementations for several types out of the box in theAggregating
companion object:scala.collection.GenTraversable
String
Array
java.util.Collection
java.util.Map
The
contain
syntax enabled by this trait is:result
should
contain
atLeastOneOf
(1, 2, 3)
result
should
contain
atMostOneOf
(1, 2, 3)
result
should
contain
only
(1, 2, 3)
result
should
contain
allOf
(1, 2, 3)
result
should
contain
theSameElementsAs
(List(1, 2, 3))
You can enable the
contain
matcher syntax enabled byAggregating
on your own typeU
by defining anAggregating[U]
for the type and making it available implicitly.Note, for an explanation of the difference between
Containing
andAggregating
, both of which enablecontain
matcher syntax, see the Containing versus Aggregating section of the main documentation for traitContaining
.