org.scalatest.words

BeWord

final class BeWord extends AnyRef

This class is part of the ScalaTest matchers DSL. Please see the documentation for ShouldMatchers or MustMatchers for an overview of the matchers DSL.

Class BeWord contains an apply method that takes a Symbol, which uses reflection to find and access a Boolean property and determine if it is true. If the symbol passed is 'empty, for example, the apply 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 type Boolean. If a method, it must take no parameters and return Boolean. If multiple candidates are found, the apply method will select based on the following algorithm:

FieldMethod"is" MethodResult
   Throws TestFailedException, because no candidates found
  isEmpty()Invokes isEmpty()
 empty() Invokes empty()
 empty()isEmpty()Invokes empty() (this can occur when BeanProperty annotation is used)
empty  Accesses field empty
empty isEmpty()Invokes isEmpty()
emptyempty() Invokes empty()
emptyempty()isEmpty()Invokes empty() (this can occur when BeanProperty annotation is used)

Source
BeWord.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. BeWord
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new BeWord()

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def <[T](right: T)(implicit arg0: Ordering[T]): Matcher[T]

    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))
                          ^
    

  5. def <=[T](right: T)(implicit arg0: Ordering[T]): Matcher[T]

    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))
                          ^
    

  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. def >[T](right: T)(implicit arg0: Ordering[T]): Matcher[T]

    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))
                          ^
    

  9. def >=[T](right: T)(implicit arg0: Ordering[T]): Matcher[T]

    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))
                          ^
    

  10. def a[S](aMatcher: AMatcher[S]): Matcher[S]

    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) }
                      ^
    

  11. def a[S <: AnyRef](bePropertyMatcher: BePropertyMatcher[S]): Matcher[S]

    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) }
                             ^
    

  12. def a(right: Symbol): Matcher[AnyRef]

    This method enables the following syntax:

    This method enables the following syntax:

    fileMock should not { be a ('file) }
                             ^
    

  13. def an[S](anMatcher: AnMatcher[S]): Matcher[S]

    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) }
                      ^
    

  14. def an[S <: AnyRef](bePropertyMatcher: BePropertyMatcher[S]): Matcher[S]

    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) }
                             ^
    

  15. def an(right: Symbol): Matcher[AnyRef]

    This method enables the following syntax:

    This method enables the following syntax:

    animal should not { be an ('elephant) }
                           ^
    

  16. def apply(defined: DefinedWord): MatcherFactory1[Any, Definition]

    This method enables syntax such as the following:

    This method enables syntax such as the following:

    array should be (defined)
                    ^
    

  17. def apply(empty: EmptyWord): MatcherFactory1[Any, Emptiness]

    This method enables syntax such as the following:

    This method enables syntax such as the following:

    array should be (empty)
                    ^
    

  18. def apply(writable: WritableWord): MatcherFactory1[Any, Writability]

    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)
                    ^
    

  19. def apply(readable: ReadableWord): MatcherFactory1[Any, Readability]

    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)
                   ^
    

  20. def apply(anType: ResultOfAnTypeInvocation[_]): Matcher[Any]

    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])
                  ^
    

  21. def apply(aType: ResultOfATypeInvocation[_]): Matcher[Any]

    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])
                  ^
    

  22. def apply[A, U <: PartialFunction[A, _]](resultOfDefinedAt: ResultOfDefinedAt[A]): Matcher[U]

    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)))
                     ^
    

  23. def apply(right: SortedWord): MatcherFactory1[Any, Sortable]

    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)
                             ^
    

  24. def apply(right: Any): Matcher[Any]

    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)
                  ^
    

  25. def apply[T](bePropertyMatcher: BePropertyMatcher[T]): Matcher[T]

    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)
                   ^
    

  26. def apply[T](right: BeMatcher[T]): Matcher[T]

    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)
                  ^
    

  27. def apply(right: Symbol): Matcher[AnyRef]

    This method enables the following syntax:

    This method enables the following syntax:

    set should be ('empty)
                  ^
    

  28. def apply(o: Null): Matcher[AnyRef]

    This method enables the following syntax:

    This method enables the following syntax:

    result should be (null)
                     ^
    

  29. def apply(right: Boolean): Matcher[Boolean]

    This method enables the following syntax:

    This method enables the following syntax:

    result should be (true)
                     ^
    

  30. def apply[U](spread: Spread[U]): Matcher[U]

    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)
                         ^
    

  31. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  32. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  33. def definedAt[A, U <: PartialFunction[A, _]](right: A): Matcher[U]

    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))
                        ^
    

  34. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  35. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  36. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  37. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  38. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  39. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  40. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  41. final def notify(): Unit

    Definition Classes
    AnyRef
  42. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  43. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  44. def theSameInstanceAs(right: AnyRef): Matcher[AnyRef]

    This method enables the following syntax:

    This method enables the following syntax:

    result should be theSameInstancreAs (anotherObject)
                     ^
    

  45. def toString(): String

    Overrides toString to return "be"

    Overrides toString to return "be"

    Definition Classes
    BeWord → AnyRef → Any
  46. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  47. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  48. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def ===(right: Any): Matcher[Any]

    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))
                          ^
    

    Annotations
    @deprecated
    Deprecated

    The should be === syntax has been deprecated. Please use should equal, should ===, shouldEqual, should be, or shouldBe instead.

Inherited from AnyRef

Inherited from Any

Ungrouped