org.scalatest.verbs

Classes and traits that support ScalaTest DSLs.

This package is released as part of the scalatest-core module.

Type members

Classlikes

final class BehaveWord

Class that supports shared test registration via instances referenced from the behave field of FunSpecs, FlatSpecs, and WordSpecs as well as instance of their sister traits, fixture.FunSpec, fixture.FlatSpec, and fixture.WordSpec.

Class that supports shared test registration via instances referenced from the behave field of FunSpecs, FlatSpecs, and WordSpecs as well as instance of their sister traits, fixture.FunSpec, fixture.FlatSpec, and fixture.WordSpec.

This class, via the behave field, enables syntax such as the following in FunSpecs, FlatSpecs, fixture.FunSpecs, and fixture.FlatSpecs:

it should behave like nonFullStack(stackWithOneItem)
         ^

It also enables syntax such as the following syntax in WordSpecs and fixture.WordSpecs:

behave like nonEmptyStack(lastValuePushed)
^

For more information and examples of the use of behave, see the Shared tests section in the main documentation for trait FunSpec, FlatSpec, or WordSpec.

trait CanVerb

Provides an implicit conversion that adds can methods to String to support the syntax of FlatSpec, WordSpec, org.scalatest.fixture.FlatSpec, and fixture.WordSpec.

Provides an implicit conversion that adds can methods to String to support the syntax of FlatSpec, WordSpec, org.scalatest.fixture.FlatSpec, and fixture.WordSpec.

For example, this trait enables syntax such as the following test registration in FlatSpec and fixture.FlatSpec:

"A Stack (when empty)" can "be empty" in { ... }
                      ^

It also enables syntax such as the following shared test registration in FlatSpec and fixture.FlatSpec:

"A Stack (with one item)" can behave like nonEmptyStack(stackWithOneItem, lastValuePushed)
                         ^

In addition, it supports the registration of subject descriptions in WordSpec and fixture.WordSpec, such as:

"A Stack (when empty)" can { ...
                      ^

And finally, it also supportds the registration of subject descriptions with after words in WordSpec and fixture.WordSpec. For example:

  def provide = afterWord("provide")

 "The ScalaTest Matchers DSL" can provide {
                              ^

The reason this implicit conversion is provided in a separate trait, instead of being provided directly in FlatSpec, WordSpec, fixture.FlatSpec, and fixture.WordSpec, is primarily for design symmetry with ShouldVerb and MustVerb. Both ShouldVerb and MustVerb must exist as a separate trait because an implicit conversion provided directly would conflict with the implicit conversion that provides should or must methods on String in the Matchers and MustMatchers traits.

final class CompileWord

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

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

trait MustVerb

Provides an implicit conversion that adds must methods to String to support the syntax of FlatSpec, WordSpec, fixture.FlatSpec, and fixture.WordSpec.

Provides an implicit conversion that adds must methods to String to support the syntax of FlatSpec, WordSpec, fixture.FlatSpec, and fixture.WordSpec.

For example, this trait enables syntax such as the following test registration in FlatSpec and fixture.FlatSpec:

"A Stack (when empty)" must "be empty" in { ... }
                      ^

It also enables syntax such as the following shared test registration in FlatSpec and fixture.FlatSpec:

"A Stack (with one item)" must behave like nonEmptyStack(stackWithOneItem, lastValuePushed)
                         ^

In addition, it supports the registration of subject descriptions in WordSpec and fixture.WordSpec, such as:

"A Stack (when empty)" must { ...
                      ^

And finally, it also supportds the registration of subject descriptions with after words in WordSpec and fixture.WordSpec. For example:

  def provide = afterWord("provide")

 "The ScalaTest Matchers DSL" must provide {
                              ^

The reason this implicit conversion is provided in a separate trait, instead of being provided directly in FlatSpec, WordSpec, fixture.FlatSpec, and fixture.WordSpec, is because an implicit conversion provided directly would conflict with the implicit conversion that provides must methods on String in the MustMatchers trait. By contrast, there is no conflict with the separate MustVerb trait approach, because:

  • FlatSpec, WordSpec, fixture.FlatSpec, and fixture.WordSpec mix in MustVerb directly, and

  • MustMatchers extends MustVerb, overriding the convertToStringMustWrapper implicit conversion function.

So whether or not a FlatSpec, WordSpec, fixture.FlatSpec, or fixture.WordSpec mixes in MustMatchers, there will only be one implicit conversion in scope that adds must methods to Strings.

Also, because the class of the result of the overriding convertToStringMustWrapper implicit conversion method provided in MustMatchers extends this trait's StringMustWrapperForVerb class, the four uses of must provided here are still available. These four must are in fact available to any class that mixes in MustMatchers, but each takes an implicit parameter that is provided only in FlatSpec and fixture.FlatSpec, or WordSpec and fixture.WordSpec.

final class ResultOfAfterWordApplication(val text: String, val f: () => Unit)

Class that supports the use of after words in WordSpec and fixture.WordSpec.

Class that supports the use of after words in WordSpec and fixture.WordSpec.

A ResultOfAfterWordApplication, which encapsulates the text of the after word and a block, is accepted by when, should, must, can, and that methods. For more information, see the main documentation for trait WordSpec.

abstract class ResultOfStringPassedToVerb(val verb: String, val rest: String)

Abstract class that supports test registration in FlatSpec and fixture.FlatSpec.

Abstract class that supports test registration in FlatSpec and fixture.FlatSpec.

For example, this class enables syntax such as the following pending test registration in FlatSpec and fixture.FlatSpec:

"A Stack (when empty)" should "be empty" is (pending)
                                        ^

For example, this class enables syntax such as the following tagged test registration in FlatSpec and fixture.FlatSpec:

"A Stack (when empty)" should "be empty" taggedAs(SlowTet) in { ... }
                                        ^

This class also indirectly enables syntax such as the following regular test registration in FlatSpec and fixture.FlatSpec:

"A Stack (when empty)" should "be empty" in { ... }
                                        ^

However, this class does not declare any methods named in, because the type passed to in differs in a FlatSpec and a fixture.FlatSpec. A fixture.FlatSpec needs two in methods, one that takes a no-arg test function and another that takes a one-arg test function (a test that takes a Fixture as its parameter). By constrast, a FlatSpec needs only one in method that takes a by-name parameter. As a result, FlatSpec and fixture.FlatSpec each provide an implicit conversion from ResultOfStringPassedToVerb to a type that provides the appropriate in methods.

abstract class ResultOfTaggedAsInvocation(val verb: String, val rest: String, val tags: List[Tag])

Supports the registration of tagged tests in shorthand form in FlatSpec and fixture.FlatSpec.

Supports the registration of tagged tests in shorthand form in FlatSpec and fixture.FlatSpec.

For example, this class enables syntax such as the following tagged, pending test registration in shorthand form:

"A Stack (when empty)" should "be empty" taggedAs() is (pending)
                                                   ^

In addition, this class indirectly enables syntax such as the following tagged test registration in shorthand form:

"A Stack (when empty)" should "be empty" taggedAs() in { ... }
                                                   ^

Rather than provide in and ignore methods directly, these methods are provided after taggedAs() by implicit conversions because the type passed to in (and ignore) differs in a FlatSpec and a fixture.FlatSpec. A fixture.FlatSpec needs two in methods, one that takes a no-arg test function and another that takes a one-arg test function (a test that takes a Fixture as its parameter). By constrast, a FlatSpec needs only one in method that takes a by-name parameter. As a result, FlatSpec and fixture.FlatSpec each provide an implicit conversion from ResultOfTaggedAsInvocation to a type that provides the appropriate in methods.

Provides an implicit conversion that adds should methods to String to support the syntax of FlatSpec, WordSpec, fixture.FlatSpec, and fixture.WordSpec.

Provides an implicit conversion that adds should methods to String to support the syntax of FlatSpec, WordSpec, fixture.FlatSpec, and fixture.WordSpec.

For example, this trait enables syntax such as the following test registration in FlatSpec and fixture.FlatSpec:

"A Stack (when empty)" should "be empty" in { ... }
                      ^

It also enables syntax such as the following shared test registration in FlatSpec and fixture.FlatSpec:

"A Stack (with one item)" should behave like nonEmptyStack(stackWithOneItem, lastValuePushed)
                         ^

In addition, it supports the registration of subject descriptions in WordSpec and fixture.WordSpec, such as:

"A Stack (when empty)" should { ...
                      ^

And finally, it also supportds the registration of subject descriptions with after words in WordSpec and fixture.WordSpec. For example:

  def provide = afterWord("provide")

 "The ScalaTest Matchers DSL" should provide {
                              ^

The reason this implicit conversion is provided in a separate trait, instead of being provided directly in FlatSpec, WordSpec, fixture.FlatSpec, and fixture.WordSpec, is because an implicit conversion provided directly would conflict with the implicit conversion that provides should methods on String in the Matchers trait. By contrast, there is no conflict with the separate ShouldVerb trait approach, because:

  • FlatSpec, WordSpec, fixture.FlatSpec, and fixture.WordSpec mix in ShouldVerb directly, and

  • Matchers extends ShouldVerb, overriding the convertToStringShouldWrapper implicit conversion function.

So whether or not a FlatSpec, WordSpec, fixture.FlatSpec, or fixture.WordSpec mixes in Matchers, there will only be one implicit conversion in scope that adds should methods to Strings.

Also, because the class of the result of the overriding convertToStringShouldWrapper implicit conversion method provided in Matchers extends this trait's StringShouldWrapperForVerb class, the four uses of should provided here are still available. These four should are in fact available to any class that mixes in Matchers, but each takes an implicit parameter that is provided only in FlatSpec and fixture.FlatSpec, or WordSpec and fixture.WordSpec.

Class that provides a role-specific type for an implicit conversion used to support the registration of subject descriptions in FlatSpec and FreeSpec styles.

Class that provides a role-specific type for an implicit conversion used to support the registration of subject descriptions in FlatSpec and FreeSpec styles.

For example, this class enables syntax such as the following in WordSpec and fixture.WordSpec:

"A Stack (when empty)" should { ...
                      ^

This should method, which is provided in ShouldVerb, needs an implicit parameter of type StringVerbBlockRegistration.

Class that provides a role-specific type for an implicit conversion used to support the registration of subject descriptions in WordSpec and fixture.WordSpec.

Class that provides a role-specific type for an implicit conversion used to support the registration of subject descriptions in WordSpec and fixture.WordSpec.

For example, this class enables syntax such as the following in WordSpec and fixture.WordSpec:

"A Stack (when empty)" should { ...
                      ^

This should method, which is provided in ShouldVerb, needs an implicit parameter of type StringVerbBlockRegistration.

Class that provides a role-specific type for an implicit conversion used to support the registration of subject descriptions in FlatSpec and FreeSpec styles.

Class that provides a role-specific type for an implicit conversion used to support the registration of subject descriptions in FlatSpec and FreeSpec styles.

For example, this class enables syntax such as the following in WordSpec and fixture.WordSpec:

"A Stack (when empty)" should { ...
                      ^

This should method, which is provided in ShouldVerb, needs an implicit parameter of type StringVerbBlockRegistration.

Class that provides a role-specific type for an implicit conversion used to support the registration of subject descriptions in FlatSpec and FreeSpec styles.

Class that provides a role-specific type for an implicit conversion used to support the registration of subject descriptions in FlatSpec and FreeSpec styles.

For example, this class enables syntax such as the following in WordSpec and fixture.WordSpec:

"A Stack (when empty)" should { ...
                      ^

This should method, which is provided in ShouldVerb, needs an implicit parameter of type StringVerbBlockRegistration.

final class TypeCheckWord

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

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