package enablers
- Alphabetic
- Public
- All
Type Members
-
trait
Aggregating[-A] extends AnyRef
Typeclass that enables for aggregations certain
containsyntax in the ScalaTest matchers DSL.Typeclass that enables for aggregations certain
containsyntax in the ScalaTest matchers DSL.An
Aggregating[A]provides access to the "aggregating nature" of typeAin such a way that relevantcontainmatcher syntax can be used with typeA. AnAcan 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 theAggregatingcompanion object:scala.collection.GenTraversableStringArrayjava.util.Collectionjava.util.Map
The
containsyntax enabled by this trait is:resultshouldcontainatLeastOneOf(1, 2, 3)resultshouldcontainatMostOneOf(1, 2, 3)resultshouldcontainonly(1, 2, 3)resultshouldcontainallOf(1, 2, 3)resultshouldcontaintheSameElementsAs(List(1, 2, 3))
You can enable the
containmatcher syntax enabled byAggregatingon your own typeUby defining anAggregating[U]for the type and making it available implicitly.Note, for an explanation of the difference between
ContainingandAggregating, both of which enablecontainmatcher syntax, see the Containing versus Aggregating section of the main documentation for traitContaining. - trait AggregatingHighPriorityImplicits extends AggregatingStandardImplicits
- trait AggregatingImpls extends AnyRef
- trait AggregatingJavaImplicits extends AggregatingImpls
- trait AggregatingStandardImplicits extends AggregatingJavaImplicits
-
trait
Collecting[E, C] extends AnyRef
Supertrait for typeclasses that enable
loneElementand inspectors syntax for collections.Supertrait for typeclasses that enable
loneElementand inspectors syntax for collections.A
Collecting[E, C]provides access to the "collecting nature" of typeCin such a way thatloneElementsyntax can be used with typeC. ACcan be any type of "collecting", a type that in some way collects or brings together elements of typeE. ScalaTest provides implicit implementations for several types. You can enable thecontainmatcher syntax on your own typeUby defining anCollecting[E, U]for the type and making it available implicitly.ScalaTest provides implicit
Collectinginstances forscala.collection.GenTraversable,Array,java.util.Collectionandjava.util.Mapin theCollectingcompanion object. -
trait
Containing[-C] extends AnyRef
Supertrait for typeclasses that enable certain
containmatcher syntax for containers.Supertrait for typeclasses that enable certain
containmatcher syntax for containers.A
Containing[C]provides access to the "containing nature" of typeCin such a way that relevantcontainmatcher syntax can be used with typeC. ACcan 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 thecontainmatcher syntax on your own typeUby defining anContaining[U]for the type and making it available implicitly.ScalaTest provides implicit
Containinginstances forscala.collection.GenTraversable,java.util.Collection,java.util.Map,String,Array, andscala.Optionin theContainingcompanion object.ContainingversusAggregatingThe difference between
ContainingandAggregatingis thatContainingenablescontainmatcher syntax that makes sense for "box" types that can contain at most one value (for example,scala.Option), whereasAggregatingenablescontainmatcher 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 byContaining, forscala.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.Optioncan only ever contain at most one object, it doesn't make sense to make assertions like the following, which are enabled viaAggregation:// 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
containallOfis enabled byAggregating, and ScalaTest provides no implicitAggregatinginstance for typescala.Option. - trait ContainingHighPriorityImplicits extends ContainingStandardImplicits
- trait ContainingImpls extends AnyRef
- trait ContainingStandardImplicits extends JavaContainingImplicits
-
trait
Definition[-T] extends AnyRef
Supertrait for typeclasses that enable the
be definedmatcher syntax.Supertrait for typeclasses that enable the
be definedmatcher syntax.A
Definition[T]provides access to the "definition nature" of typeSin such a way thatbe definedmatcher syntax can be used with typeT. ATcan be any type for which the concept of being defined makes sense, such asscala.Option. ScalaTest provides implicit implementation forscala.Option. You can enable thebe definedmatcher syntax on your own typeUby defining aDefinition[U]for the type and making it available implicitly.ScalaTest provides an implicit
Definitioninstance forscala.Option, arbitary object withisDefined()orisDefinedin theDefinitioncompanion object. -
trait
Emptiness[-T] extends AnyRef
Supertrait for typeclasses that enable
be emptymatcher syntax.Supertrait for typeclasses that enable
be emptymatcher syntax.An
Emptiness[T]provides access to the "emptiness" of typeTin such a way thatbe emptymatcher syntax can be used with typeT. ATcan be any type that in some way can be empty. ScalaTest provides implicit implementations for several types. You can enable thebe emptymatcher syntax on your own typeUby defining anEmptiness[U]for the type and making it available implicitly.ScalaTest provides implicit
Emptinessinstances forscala.collection.GenTraversable,java.util.Collection,java.util.Map,String,Array, andscala.Optionin theEmptinesscompanion object. -
trait
Existence[-S] extends AnyRef
Supertrait for typeclasses that enable the
existmatcher syntax.Supertrait for typeclasses that enable the
existmatcher syntax.An
Existence[S]provides access to the "existence nature" of typeSin such a way thatexistmatcher syntax can be used with typeS. AScan be any type for which the concept of existence makes sense, such asjava.io.File. ScalaTest provides implicit implementations forjava.io.File. You can enable theexistmatcher syntax on your own typeUby defining aExistence[U]for the type and making it available implicitly.ScalaTest provides an implicit
Existenceinstance forjava.io.Filein theExistencecompanion object. -
trait
Futuristic[T] extends AnyRef
Supertrait for
Futureistictypeclasses.Supertrait for
Futureistictypeclasses.Trait
Futureisticis a typeclass trait for objects that can be used with thecomplete-lastlysyntax of traitCompleteLastly. -
trait
InspectorAsserting[T] extends AnyRef
Supertrait for
InspectorAssertingtypeclasses, which are used to implement and determine the result type ofInspectorsmethods such asforAll,forBetween, etc.Supertrait for
InspectorAssertingtypeclasses, which are used to implement and determine the result type ofInspectorsmethods such asforAll,forBetween, etc.Currently, an inspector expression will have result type
Assertion, if the function passed has result typeAssertion, else it will have result typeUnit. - trait JavaContainingImplicits extends ContainingImpls
-
trait
KeyMapping[-M] extends AnyRef
Supertrait for typeclasses that enable
contain keymatcher syntax.Supertrait for typeclasses that enable
contain keymatcher syntax.A
KeyMapping[M]provides access to the "key mapping nature" of typeMin such a way thatcontain keymatcher syntax can be used with typeM. AMcan be any type for whichcontain keysyntax makes sense. ScalaTest provides implicit implementations forscala.collection.GenMapandjava.util.Map. You can enable thecontain keymatcher syntax on your own typeUby defining aKeyMapping[U]for the type and making it available implicitly.ScalaTest provides implicit
KeyMappinginstances forscala.collection.GenMap, andjava.util.Mapin theKeyMappingcompanion object. -
trait
Length[T] extends AnyRef
Supertrait for
Lengthtypeclasses.Supertrait for
Lengthtypeclasses.Trait
Lengthis a typeclass trait for objects that can be queried for length. Objects of type T for which an implicitLength[T]is available can be used with theshould have lengthsyntax. In other words, this trait enables you to use the length checking syntax with arbitrary objects. As an example, the followingBridgeclass: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 lengthsyntax withBridge, 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@3fa27a4aWith the implicit
Length[Bridge]in scope, you can now use ScalaTest'sshould have lengthsyntax withBridgeinstances: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
-
trait
Messaging[T] extends AnyRef
Supertrait for
Messagingtypeclasses.Supertrait for
Messagingtypeclasses.Trait
Messagingis a typeclass trait for objects that can be queried for message. Objects of type T for which an implicitMessaging[T]is available can be used with theshould have messagesyntax. You can enable thehave messagematcher syntax on your own typeUby defining aMessaging[U]for the type and making it available implicitly.ScalaTest provides an implicit
Messaginginstance forjava.lang.Throwableand arbitary object withmessage(),message,getMessage()orgetMessagemethod in theMessagingcompanion object. -
trait
Readability[-T] extends AnyRef
Supertrait for typeclasses that enable the
be readablematcher syntax.Supertrait for typeclasses that enable the
be readablematcher syntax.A
Readability[T]provides access to the "readable nature" of typeTin such a way thatbe readablematcher syntax can be used with typeT. ATcan be any type for which the concept of being readable makes sense, such asjava.io.File. You can enable thebe readablematcher syntax on your own typeUby defining aReadability[U]for the type and making it available implicitly.ScalaTest provides an implicit
Readabilityinstance forjava.io.Fileand arbitary object withisReadable()orisReadablein theReadabilitycompanion object. -
trait
Sequencing[-S] extends AnyRef
Typeclass that enables for sequencing certain
containsyntax in the ScalaTest matchers DSL.Typeclass that enables for sequencing certain
containsyntax in the ScalaTest matchers DSL.An
Sequencing[A]provides access to the "sequenching nature" of typeAin such a way that relevantcontainmatcher syntax can be used with typeA. AnAcan 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 theSequencingcompanion object:scala.collection.GenSeqscala.collection.SortedSetscala.collection.SortedMapArrayjava.util.Listjava.util.SortedSetjava.util.SortedMapString
The
containsyntax 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
containmatcher syntax enabled bySequencingon your own typeUby defining anSequencing[U]for the type and making it available implicitly. -
trait
Size[T] extends AnyRef
Supertrait for
Sizetypeclasses.Supertrait for
Sizetypeclasses.Trait
Sizeis a typeclass trait for objects that can be queried for size. Objects of type T for which an implicitSize[T]is available can be used with theshould have sizesyntax. In other words, this trait enables you to use the size checking syntax with arbitrary objects. As an example, the followingBridgeclass: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 sizesyntax withBridge, 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@3fa27a4aWith the implicit
Size[Bridge]in scope, you can now use ScalaTest'sshould have sizesyntax withBridgeinstances: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
-
trait
Sortable[-S] extends AnyRef
Supertrait for typeclasses that enable the
besortedmatcher syntax.Supertrait for typeclasses that enable the
besortedmatcher syntax.A
Sortable[S]provides access to the "sortable nature" of typeSin such a way thatbesortedmatcher syntax can be used with typeS. AnScan 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 thebesortedmatcher syntax on your own typeUby defining aSortable[U]for the type and making it available implicitly.ScalaTest provides an implicit
Sortableinstance for types out of the box in theSortablecompanion object:scala.collection.GenSeqArrayjava.util.List
-
trait
TableAsserting[ASSERTION] extends AnyRef
Supertrait for
TableAssertingtypeclasses, which are used to implement and determine the result type of TableDrivenPropertyChecks'sforAll,forEveryandexistsmethod.Supertrait for
TableAssertingtypeclasses, which are used to implement and determine the result type of TableDrivenPropertyChecks'sforAll,forEveryandexistsmethod.Currently, an TableDrivenPropertyChecks expression will have result type
Assertion, if the function passed has result typeAssertion, else it will have result typeUnit. -
trait
Timed[T] extends AnyRef
Trait that provides a
timeoutAfterconstruct, 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. -
abstract
class
UnitCheckerAsserting extends AnyRef
Class holding lowest priority
CheckerAssertingimplicit, which enables GeneratorDrivenPropertyChecks expressions that have result typeUnit. -
abstract
class
UnitInspectorAsserting extends AnyRef
Class holding lowest priority
InspectorAssertingimplicit, which enables inspector expressions that have result typeUnit. -
abstract
class
UnitTableAsserting extends AnyRef
Class holding lowest priority
TableAssertingimplicit, which enables TableDrivenPropertyChecks expressions that have result typeUnit. -
abstract
class
UnitWheneverAsserting extends AnyRef
Class holding lowest priority
WheneverAssertingimplicit, which enables Whenever expressions that have result typeUnit. -
trait
ValueMapping[-M] extends AnyRef
Supertrait for typeclasses that enable
contain valuematcher syntax.Supertrait for typeclasses that enable
contain valuematcher syntax.A
ValueMapping[M]provides access to the "value mapping nature" of typeMin such a way thatcontainvaluematcher syntax can be used with typeM. AnMcan be any type for whichcontainvaluesyntax makes sense. ScalaTest provides implicit implementations forscala.collection.GenMapandjava.util.Map. You can enable thecontainvaluematcher syntax on your own typeUby defining aValueMapping[U]for the type and making it available implicitly.ScalaTest provides implicit
ValueMappinginstances forscala.collection.GenMap, andjava.util.Mapin theValueMappingcompanion object. -
trait
WheneverAsserting[T] extends AnyRef
Supertrait for
WheneverAssertingtypeclasses, which are used to implement and determine the result type of Whenever'swhenevermethod. -
trait
Writability[-T] extends AnyRef
Supertrait for typeclasses that enable the
bewritablematcher syntax.Supertrait for typeclasses that enable the
bewritablematcher syntax.A
Writability[T]provides access to the "writable nature" of typeTin such a way thatbewritablematcher syntax can be used with typeT. ATcan be any type for which the concept of being writable makes sense, such asjava.io.File. ScalaTest provides implicit implementation forjava.io.File. You can enable thebewritablematcher syntax on your own typeUby defining aWritability[U]for the type and making it available implicitly.ScalaTest provides an implicit
Writabilityinstance forjava.io.Fileand arbitary object withisWritable()orisWritablein theWritabilitycompanion object. -
trait
CheckerAsserting[T] extends AnyRef
Supertrait for
CheckerAssertingtypeclasses, which are used to implement and determine the result type of GeneratorDrivenPropertyChecks'sapplyandforAllmethod.Supertrait for
CheckerAssertingtypeclasses, which are used to implement and determine the result type of GeneratorDrivenPropertyChecks'sapplyandforAllmethod.Currently, an GeneratorDrivenPropertyChecks expression will have result type
Assertion, if the function passed has result typeAssertion, else it will have result typeUnit.- Annotations
- @deprecated
- Deprecated
CheckerCheckerAssertings has been moved from org.scalatest.enablers to org.scalatestplus.scalacheck. Please update your imports, as this deprecated type will be removed in a future version of ScalaTest.
Value Members
-
object
Aggregating extends AggregatingHighPriorityImplicits
Companion object for
Aggregatingthat provides implicit implementations for the following types:Companion object for
Aggregatingthat provides implicit implementations for the following types:scala.collection.GenTraversableStringArrayjava.util.Collectionjava.util.Map
-
object
Collecting
Companion object for
Collectingthat provides implicit implementations for the following types:Companion object for
Collectingthat provides implicit implementations for the following types:scala.collection.GenTraversableArrayjava.util.Collectionjava.util.Map
-
object
Containing extends ContainingHighPriorityImplicits
Companion object for
Containingthat provides implicit implementations for the following types:Companion object for
Containingthat provides implicit implementations for the following types:scala.collection.GenTraversableStringArrayscala.Optionjava.util.Collectionjava.util.Map
-
object
Definition
Companion object for
Definitionthat provides implicit implementations for the following types:Companion object for
Definitionthat provides implicit implementations for the following types:scala.Option- arbitary object with a
isDefined()method that returnsBoolean - arbitary object with a parameterless
isDefinedmethod that returnsBoolean
-
object
Emptiness
Companion object for
Emptinessthat provides implicit implementations for the following types:Companion object for
Emptinessthat provides implicit implementations for the following types:scala.collection.GenTraversableStringArrayscala.Optionjava.util.Collectionjava.util.Map- arbitary object with a
isEmpty()method that returnsBoolean - arbitary object with a parameterless
isEmptymethod that returnsBoolean
-
object
Existence
Companion object for
Existencethat provides implicit implementations forjava.io.File. -
object
Futuristic
Companion object for trait
Futuristicthat contains implicitFuturisticproviders forFutureOutcomeandFuture[T]for any typeT. -
object
InspectorAsserting extends UnitInspectorAsserting
Companion object to
InspectorAssertingthat provides two implicit providers, a higher priority one for passed functions that have result typeAssertion, which also yields result typeAssertion, and one for any other type, which yields result typeUnit. -
object
KeyMapping
Companion object for
KeyMappingthat provides implicit implementations forscala.collection.GenMapandjava.util.Map. -
object
Length
Companion object for
Lengththat provides implicit implementations for the following types:Companion object for
Lengththat provides implicit implementations for the following types:scala.collection.GenSeqStringArrayjava.util.Collection- arbitary object with a
length()method that returnsInt - arbitary object with a parameterless
lengthmethod that returnsInt - arbitary object with a
getLength()method that returnsInt - arbitary object with a parameterless
getLengthmethod that returnsInt - arbitary object with a
length()method that returnsLong - arbitary object with a parameterless
lengthmethod that returnsLong - arbitary object with a
getLength()method that returnsLong - arbitary object with a parameterless
getLengthmethod that returnsLong
-
object
Messaging
Companion object for
Messagingthat provides implicit implementations for the following types:Companion object for
Messagingthat provides implicit implementations for the following types:java.lang.Throwable- arbitary object with a
message()method that returnsString - arbitary object with a parameterless
messagemethod that returnsString - arbitary object with a
getMessage()method that returnsString - arbitary object with a parameterless
getMessagemethod that returnsString
-
object
Readability
Companion object for
Readabilitythat provides implicit implementations for the following types:Companion object for
Readabilitythat provides implicit implementations for the following types:java.io.File- arbitary object with a
isReadable()method that returnsBoolean - arbitary object with a parameterless
isReadablemethod that returnsBoolean
-
object
Sequencing
Companion object for
Sequencingthat provides implicit implementations for the following types:Companion object for
Sequencingthat provides implicit implementations for the following types:scala.collection.GenSeqscala.collection.SortedSetscala.collection.SortedMapArrayjava.util.Listjava.util.SortedSetjava.util.SortedMapString
-
object
Size
Companion object for
Sizethat provides implicit implementations for the following types:Companion object for
Sizethat provides implicit implementations for the following types:scala.collection.GenTraversableStringArrayjava.util.Collectionjava.util.Map- arbitary object with a
size()method that returnsInt - arbitary object with a parameterless
sizemethod that returnsInt - arbitary object with a
getSize()method that returnsInt - arbitary object with a parameterless
getSizemethod that returnsInt - arbitary object with a
size()method that returnsLong - arbitary object with a parameterless
sizemethod that returnsLong - arbitary object with a
getSize()method that returnsLong - arbitary object with a parameterless
getSizemethod that returnsLong
-
object
Sortable
Companion object for
Sortablethat provides implicit implementations for the following types:Companion object for
Sortablethat provides implicit implementations for the following types:scala.collection.GenSeqArrayjava.util.List
-
object
TableAsserting extends UnitTableAsserting
Companion object to
TableAssertingthat provides two implicit providers, a higher priority one for passed functions that have result typeAssertion, which also yields result typeAssertion, and one for any other type, which yields result typeUnit. -
object
Timed
Companion object for
Timedtypeclass that offers three implicit providers: one forFutureOutcome, one forFutureof any type, and one for any other type.Companion object for
Timedtypeclass that offers three implicit providers: one forFutureOutcome, one forFutureof any type, and one for any other type.The details are in the documentation for the implicit providers themselves (methods
timed,timedFutureOf, andtimedFutureOutcome), but in short if a time limit is exceeded:- if the type
TinTimed[T]isFutureOutcometheFutureOutcomereturned bytimeoutAfterwill result in eitherFailedorCanceled - if the type is
Future[U], theFuture[U]returned bytimeoutAfterwill fail with either aTestFailedDueToTimeoutExceptionor aTestCanceledException. - otherwise, the
timeoutAftermethod will itself complete abruptly with eitherTestFailedDueToTimeoutExceptionorTestCanceledException.
- if the type
-
object
ValueMapping
Companion object for
ValueMappingthat provides implicit implementations forscala.collection.GenMapandjava.util.Map. -
object
WheneverAsserting extends UnitWheneverAsserting
Companion object to
WheneverAssertingthat provides two implicit providers, a higher priority one for passed functions that have result typeAssertion, which also yields result typeAssertion, and one for any other type, which yields result typeUnit. -
object
Writability
Companion object for
Writabilitythat provides implicit implementations for the following types:Companion object for
Writabilitythat provides implicit implementations for the following types:java.io.File- arbitary object with a
isWritable()method that returnsBoolean - arbitary object with a parameterless
isWritablemethod that returnsBoolean
Deprecated Value Members
-
object
CheckerAsserting extends UnitCheckerAsserting
Companion object to
CheckerAssertingthat provides two implicit providers, a higher priority one for passed functions that have result typeAssertion, which also yields result typeAssertion, and one for any other type, which yields result typeUnit.Companion object to
CheckerAssertingthat provides two implicit providers, a higher priority one for passed functions that have result typeAssertion, which also yields result typeAssertion, and one for any other type, which yields result typeUnit.- Annotations
- @deprecated
- Deprecated
CheckerCheckerAssertings has been moved from org.scalatest.enablers to org.scalatestplus.scalacheck. Please update your imports, as this deprecated type will be removed in a future version of ScalaTest.