org.scalacheck.commands

Commands

Related Doc: package commands

trait Commands extends AnyRef

An API for stateful testing in ScalaCheck.

For an implementation overview, see the examples in ScalaCheck's source tree.

Source
Commands.scala
Since

1.12.0

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

Type Members

  1. trait Command extends AnyRef

    A type representing the commands that can run in the system under test.

    A type representing the commands that can run in the system under test. This type should be immutable and implement the equality operator properly.

  2. abstract type State

    The abstract state type.

    The abstract state type. Must be immutable. The State type should model the state of the system under test (SUT). It should only contain details needed for specifying our pre- and postconditions, and for creating Sut instances.

  3. trait SuccessCommand extends Command

    A command that never should throw an exception on execution.

  4. abstract type Sut

    A type representing one instance of the system under test (SUT).

    A type representing one instance of the system under test (SUT). The Sut type should be a proxy to the actual system under test and is therefore, by definition, a mutable type. It is used by the Command.run method to execute commands in the system under test. It should be possible to have any number of co-existing instances of the Sut type, as long as canCreateNewSut isn't violated, and each Sut instance should be a proxy to a distinct SUT instance. There should be no dependencies between the Sut instances, as they might be used in parallel by ScalaCheck. Sut instances are created by newSut and destroyed by destroySut. newSut and destroySut might be called at any time by ScalaCheck, as long as canCreateNewSut isn't violated.

  5. trait UnitCommand extends Command

    A command that doesn't return a result, only succeeds or fails.

Abstract Value Members

  1. abstract def canCreateNewSut(newState: State, initSuts: Traversable[State], runningSuts: Traversable[Sut]): Boolean

    Decides if newSut should be allowed to be called with the specified state instance.

    Decides if newSut should be allowed to be called with the specified state instance. This can be used to limit the number of co-existing Sut instances. The list of existing states represents the initial states (not the current states) for all Sut instances that are active for the moment. If this method is implemented incorrectly, for example if it returns false even if the list of existing states is empty, ScalaCheck might hang.

    If you want to allow only one Sut instance to exist at any given time (a singleton Sut), implement this method the following way:

    def canCreateNewSut(newState: State, initSuts: Traversable[State]
      runningSuts: Traversable[Sut]
    ) = {
      initSuts.isEmpty && runningSuts.isEmpty
    }
  2. abstract def destroySut(sut: Sut): Unit

    Destroy the system represented by the given Sut instance, and release any resources related to it.

  3. abstract def genCommand(state: State): Gen[Command]

    A generator that, given the current abstract state, should produce a suitable Command instance.

  4. abstract def genInitialState: Gen[State]

    A generator that should produce an initial State instance that is usable by newSut to create a new system under test.

    A generator that should produce an initial State instance that is usable by newSut to create a new system under test. The state returned by this generator is always checked with the initialPreCondition method before it is used.

  5. abstract def initialPreCondition(state: State): Boolean

    The precondition for the initial state, when no commands yet have run.

    The precondition for the initial state, when no commands yet have run. This is used by ScalaCheck when command sequences are shrinked and the first state might differ from what is returned from genInitialState.

  6. abstract def newSut(state: State): Sut

    Create a new Sut instance with an internal state that corresponds to the provided abstract state instance.

    Create a new Sut instance with an internal state that corresponds to the provided abstract state instance. The provided state is guaranteed to fulfill initialPreCondition, and newSut will never be called if canCreateNewSut is not true for the given state.

Concrete Value Members

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

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Definition Classes
    AnyRef → Any
  4. object NoOp extends Command with Product with Serializable

    A command that doesn't do anything

  5. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def commandSequence(head: Command, snd: Command, rest: Command*): Command

    A command that runs a sequence of other commands.

    A command that runs a sequence of other commands. All commands (and their post conditions) are executed even if some command fails. Note that you probably can't use this method if you're testing in parallel (threadCount larger than 1). This is because ScalaCheck regards each command as atomic, even if the command is a sequence of other commands.

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

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

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

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

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

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

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

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

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

    Definition Classes
    AnyRef
  17. final def property(threadCount: Int = 1, maxParComb: Int = 1000000): Prop

    A property that can be used to test this Commands specification.

    A property that can be used to test this Commands specification.

    The parameter threadCount specifies the number of commands that might be executed in parallel. Defaults to one, which means the commands will only be run serially for the same Sut instance. Distinct Sut instances might still receive commands in parallel, if the Test.Parameters.workers parameter is larger than one. Setting threadCount higher than one enables ScalaCheck to reveal thread-related issues in your system under test.

    When setting threadCount larger than one, ScalaCheck must evaluate all possible command interleavings (and the end State instances they produce), since parallel command execution is non-deterministic. ScalaCheck tries out all possible end states with the Command.postCondition function of the very last command executed (there is always exactly one command executed after all parallel command executions). If it fails to find an end state that satisfies the postcondition, the test fails. However, the number of possible end states grows rapidly with increasing values of threadCount. Therefore, the lengths of the parallel command sequences are limited so that the number of possible end states don't exceed maxParComb. The default value of maxParComb is 1000000.

  18. def shrinkState: Shrink[State]

    Override this to provide a custom Shrinker for your internal State.

    Override this to provide a custom Shrinker for your internal State. By default no shrinking is done for State.

  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  20. def toString(): String

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

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped