org.specs2.specification.core

Type members

Classlikes

trait AsExecution[T]
Companion:
object
Companion:
class
case class Backtab(n: Int) extends Description

The next fragment must be un-indented

The next fragment must be un-indented

case object Br extends Description

Break (== new line)

Break (== new line)

case class Code(text: String) extends Description

Description of a Fragment

Description of a Fragment

Companion:
object

Creation methods for Descriptions

Creation methods for Descriptions

Companion:
class
case object End extends Description

End of a block

End of a block

case class Env(arguments: Arguments, systemLogger: Logger, selectorInstance: Arguments => Selector, executorInstance: Arguments => Executor, lineLogger: LineLogger, statsRepository: Arguments => StatisticsRepository, random: Random, fileSystem: FileSystem, executionParameters: ExecutionParameters, customClassLoader: Option[ClassLoader], classLoading: ClassLoading, executionEnv: ExecutionEnv, specs2ExecutionEnv: ExecutionEnv)

Whole creation / execution / reporting environment for a specification

Whole creation / execution / reporting environment for a specification

Part of it is driven by the command-line, part of it is specs2 implementation Yet it can be used to drive the creation or execution of examples

Note: creating an Env instance is a delicate activity because the Env hold a thread pool that needs to be shutdown at the end of the execution

Companion:
object
object Env
Companion:
class
object EnvDefault
case class ExecutedResult(result: Result, timer: SimpleTimer)
sealed trait Executing
case class Execution(run: Option[Env => Future[() => Result]], executing: Executing, timeout: Option[FiniteDuration], mustJoin: Boolean, nextMustStopIf: Result => Boolean, isolable: Boolean, previousResult: Option[Result], finalResultMap: Option[Result => Result], continuation: Option[FragmentsContinuation])

Execution of a Fragment

Execution of a Fragment

  • there can be none (for a piece of text)
  • the execution depends on the current Env. by default executions are created synchronously but can also be fork-off with Execution.withEnvAsync
  • it can have its own timeout (default is infinite)
  • once executed the result is kept
  • if mustJoin is true this means that all previous executions must be finished before this one can start
  • it has a condition deciding if the next execution can proceed or not depending on the current result
  • if isolable is true this means that it should be executed in its own specification instance
  • the result of a similar execution can be stored to decide if this one needs to be executed or not
  • it can store a continuation that will create more fragments, possibly containing more executions, based on the current result
Companion:
object
object Execution
Companion:
class
case class ExecutionParameters(withIsolation: Boolean)
case class Failed(failure: Throwable) extends Executing
case class FatalExecution(t: Throwable) extends Exception
Companion:
object
Companion:
class
case class Fragment(description: Description, execution: Execution, location: Location)

Fragment of a specification

Fragment of a specification

It has a description (generally text but sometimes not, for a step for example) It has an execution which might do or don't do anything (for examples it runs some code)

Companion:
object
object Fragment
Companion:
class
case class Fragments(contents: AsyncStream[Fragment])

Fragments of a specification

Fragments of a specification

It is implemented as a Process of Fragment in order to produce fragments dynamically if necessary

Companion:
object
object Fragments
Companion:
class
case class FragmentsContinuation(continue: Result => Option[Fragments])

Function creating more fragments (to be added to the specification) based on the current result

Function creating more fragments (to be added to the specification) based on the current result

Companion:
object

Structure of an immutable specification.

Structure of an immutable specification.

It may depend on the current environment.

If the examples need to be executed in their own instance of the specification they will be "isolated"

trait Location

Location of a Fragment

Location of a Fragment

This is currently implemented using stacktraces which is very brittle

case class Marker(tag: NamedTag, isSection: Boolean, appliesToNext: Boolean) extends Description

Description of a Tag fragment

Description of a Tag fragment

case object NoText extends Description

NoText description, used when creating steps and actions which are not described

NoText description, used when creating steps and actions which are not described

case object NotExecuting extends Executing
trait OwnEnv extends AfterAll

This trait copies the inherited env: Env for a Specification and makes sure it is shutdown when the specification finishes

This trait copies the inherited env: Env for a Specification and makes sure it is shutdown when the specification finishes

The specification using this trait must require an Env:

class MySpec(env: Env) extends Specification with OwnEnv

This trait provides an isolated Execution Env for a Specification and makes sure it is shutdown when the specification finishes.

This trait provides an isolated Execution Env for a Specification and makes sure it is shutdown when the specification finishes.

The specification using this trait must require an Env:

class MySpec(env: Env) extends Specification with OwnExecutionEnv

case class SimpleLocation(trace: TraceLocation) extends Location
case class SpecHeader(specClass: Class[_], title: Option[String])

Header of a Specification

Header of a Specification

It can hold a user-defined title for better presentation

Companion:
object
object SpecHeader
Companion:
class
case class SpecStructure(header: SpecHeader, arguments: Arguments, lazyFragments: () => Fragments)

Structure of a Specification:

Structure of a Specification:

  • a header
  • some arguments
  • specification fragments

Note that the fragments have to be lazy in order to avoid cycles when 2 specifications are referencing each other with links

Companion:
object

Create SpecStructures from header, arguments, fragments

Create SpecStructures from header, arguments, fragments

Companion:
class
case class SpecificationRef(header: SpecHeader, arguments: Arguments, alias: String, tooltip: String, hidden: Boolean, muted: Boolean) extends Description

Reference to another specification

Reference to another specification

Companion:
object
Companion:
class
@EnableReflectiveInstantiation
Companion:
object
case class StacktraceLocation(trace: Seq[StackTraceElement]) extends Location
case object Start extends Description

Start of a block. This is used to delimit the blocks in mutable specifications and know exactly how to create levels when transforming a specification to a tree of examples (for JUnit for example)

Start of a block. This is used to delimit the blocks in mutable specifications and know exactly how to create levels when transforming a specification to a tree of examples (for JUnit for example)

case class Started(future: Future[(Result, SimpleTimer)]) extends Executing
case class Tab(n: Int) extends Description

The next fragment must be indented

The next fragment must be indented

case class Text(text: String) extends Description

Text description

Text description