This method enables the following syntax:
This method enables the following syntax:
result should be < (7)
^
Note that the less than operator will be invoked on be
in this expression, not
on a result of passing be
to should
, as with most other operators
in the matchers DSL, because the less than operator has a higher precedence than should
.
Thus in the above case the first expression evaluated will be be < (7)
, which results
in a matcher that is passed to should
.
This method also enables the following syntax:
result should not (be < (7))
^
This method enables the following syntax:
This method enables the following syntax:
result should be <= (7)
^
Note that the less than or equal to operator will be invoked on be
in this expression, not
on a result of passing be
to should
, as with most other operators
in the matchers DSL, because the less than or equal to operator has a higher precedence than should
.
Thus in the above case the first expression evaluated will be be <= (7)
, which results
in a matcher that is passed to should
.
This method also enables the following syntax:
result should not (be <= (7))
^
This method enables the following syntax:
This method enables the following syntax:
result should be > (7)
^
Note that the greater than operator will be invoked on be
in this expression, not
on a result of passing be
to should
, as with most other operators
in the matchers DSL, because the greater than operator has a higher precedence than should
.
Thus in the above case the first expression evaluated will be be > (7)
, which results
in a matcher that is passed to should
.
This method also enables the following syntax:
result should not (be > (7))
^
This method enables the following syntax:
This method enables the following syntax:
result should be >= (7)
^
Note that the greater than or equal to operator will be invoked on be
in this expression, not
on a result of passing be
to should
, as with most other operators
in the matchers DSL, because the greater than or equal to operator has a higher precedence than should
.
Thus in the above case the first expression evaluated will be be >= (7)
, which results
in a matcher that is passed to should
.
This method also enables the following syntax:
result should not (be >= (7))
^
This method enables the following syntax, where negativeNumber
is, for example, of type AMatcher
:
This method enables the following syntax, where negativeNumber
is, for example, of type AMatcher
:
8 should not { be a (negativeNumber) }
^
This method enables the following syntax, where fileMock
is, for example, of type File
and
file
refers to a BePropertyMatcher[File]
:
This method enables the following syntax, where fileMock
is, for example, of type File
and
file
refers to a BePropertyMatcher[File]
:
fileMock should not { be a (file) } ^
This method enables the following syntax:
This method enables the following syntax:
fileMock should not { be a ('file) }
^
This method enables the following syntax, where oddNumber
is, for example, of type AnMatcher
:
This method enables the following syntax, where oddNumber
is, for example, of type AnMatcher
:
8 should not { be an (oddNumber) }
^
This method enables the following syntax, where keyEvent
is, for example, of type KeyEvent
and
actionKey
refers to a BePropertyMatcher[KeyEvent]
:
This method enables the following syntax, where keyEvent
is, for example, of type KeyEvent
and
actionKey
refers to a BePropertyMatcher[KeyEvent]
:
keyEvent should not { be an (actionKey) } ^
This method enables the following syntax:
This method enables the following syntax:
animal should not { be an ('elephant) }
^
This method enables syntax such as the following:
This method enables syntax such as the following:
array should be (defined) ^
This method enables syntax such as the following:
This method enables syntax such as the following:
array should be (empty) ^
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
file should be (writable) ^
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
file should be (readable) ^
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
result should be (an [Book])
^
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
result should be (a [Book])
^
This method enables the following syntax, where fraction
refers to a PartialFunction
:
This method enables the following syntax, where fraction
refers to a PartialFunction
:
fraction should (be (definedAt (6)) and be (definedAt (8))) ^
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
List(1, 2, 3) should be (sorted) ^
This method enables be
to be used for equality comparison.
This method enables be
to be used for equality comparison. Here are some examples:
result should be (None) ^ result should be (Some(1)) ^ result should be (true) ^ result should be (false) ^ sum should be (19) ^
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
This method enables the following syntax, where open
refers to a BePropertyMatcher
:
door should be (open) ^
This method enables the following syntax, where num
is, for example, of type Int
and
odd
refers to a BeMatcher[Int]
:
This method enables the following syntax, where num
is, for example, of type Int
and
odd
refers to a BeMatcher[Int]
:
num should be (odd) ^
This method enables the following syntax:
This method enables the following syntax:
set should be ('empty)
^
This method enables the following syntax:
This method enables the following syntax:
result should be (null)
^
This method enables the following syntax:
This method enables the following syntax:
result should be (true)
^
This method enables the following syntax for the "primitive" numeric types:
This method enables the following syntax for the "primitive" numeric types:
sevenDotOh should be (7.1 plusOrMinus 0.2) ^
This method enables the following syntax, where fraction
refers to a PartialFunction
:
This method enables the following syntax, where fraction
refers to a PartialFunction
:
fraction should (be definedAt (6) and be definedAt (8)) ^
This method enables the following syntax:
This method enables the following syntax:
result should be theSameInstancreAs (anotherObject) ^
Overrides toString to return "be"
Overrides toString to return "be"
The should be === syntax has been deprecated and will be removed in a future version of ScalaTest. Please use should equal, should ===, shouldEqual, should be, or shouldBe instead. Note, the reason this was deprecated was so that === would mean only one thing in ScalaTest: a customizable, type- checkable equality comparison.
The should be === syntax has been deprecated and will be removed in a future version of ScalaTest. Please use should equal, should ===, shouldEqual, should be, or shouldBe instead. Note, the reason this was deprecated was so that === would mean only one thing in ScalaTest: a customizable, type- checkable equality comparison.
This method enables the following syntax:
result should be === (7)
^
Note that the === operator will be invoked on be
in this expression, not
on a result of passing be
to should
, as with most other operators
in the matchers DSL, because the ===n operator has a higher precedence than should
.
Thus in the above case the first expression evaluated will be be === (7)
, which results
in a matcher that is passed to should
.
This method also enables the following syntax:
result should not (be === (7))
^
The should be === syntax has been deprecated. Please use should equal, should ===, shouldEqual, should be, or shouldBe instead.
This class is part of the ScalaTest matchers DSL. Please see the documentation for
ShouldMatchers
orMustMatchers
for an overview of the matchers DSL.Class
BeWord
contains anapply
method that takes aSymbol
, which uses reflection to find and access aBoolean
property and determine if it istrue
. If the symbol passed is'empty
, for example, theapply
method will use reflection to look for a public Java field named "empty", a public method named "empty", or a public method named "isEmpty". If a field, it must be of typeBoolean
. If a method, it must take no parameters and returnBoolean
. If multiple candidates are found, theapply
method will select based on the following algorithm:TestFailedException
, because no candidates foundisEmpty()
isEmpty()
empty()
empty()
empty()
isEmpty()
empty()
(this can occur whenBeanProperty
annotation is used)empty
empty
empty
isEmpty()
isEmpty()
empty
empty()
empty()
empty
empty()
isEmpty()
empty()
(this can occur whenBeanProperty
annotation is used)