org.specs.specification.ExampleWithContext

class ExampleWithContext

case class ExampleWithContext[S](val context : SystemContext[S], val exampleDesc : ExampleDescription, val cyc : ExampleLifeCycle)

 extends Example


The Example class specifies one example of a system behaviour
It has:

Usage: "this is an example" in { // code containing expectations } or
"this is an example" >> { // code containing expectations }
">>" can be used instead of "in" if that word makes no sense in the specification

An example can also contain subexamples which are executed will evaluating the in method.

When expectations have been evaluated inside an example they register their failures and errors for later reporting



Companion: ExampleWithContext

Source: Example.scala(28)

 Constructors

def this(context : SystemContext[S], exampleDesc : ExampleDescription, cyc : ExampleLifeCycle)

 Fields

acceptAnyTag def acceptAnyTag
reset accepted and rejected to an empty queue
Tagged Tagged
accepted val accepted
list of tags which are accepted for this element
Queue[Tag] Tagged
addExpectation def addExpectation
increment the number of expectations in this example
Example Example
clearTags def clearTags
Clear all tags, accepted and rejected
Tagged Tagged
cycle val cycle ExampleLifeCycle Example
description def description String Example
errors def errors
[details]
return
- the errors of this example and its subexamples, executing the example if necessary
Seq[Throwable] Example
exampleDescription var exampleDescription ExampleDescription Example
execution var execution
encapsulates the expectations to execute
ExampleExecution Example
expectationsNb def expectationsNb
[details]
return
- the number of expectations, executing the example if necessary
Int Example
failureAndErrors def failureAndErrors List[Throwable] HasResults
failures def failures
[details]
return
- the failures of this example and its subexamples, executing the example if necessary
Seq[FailureException] Example
hasFailureAndErrors def hasFailureAndErrors Boolean HasResults
hasIssues def hasIssues Boolean HasResults
isAccepted def isAccepted
Return true if this Tagged element:
  • doesn't have any tags and no tags are marked as accepted
  • or doesn't have any accepted tags
  • or has at least one of the accepted tags and doesn't have any of the rejected tags
[details]
return
- true if the element can be accepted, considering the tags it owns and the accepted/rejected tags
Boolean Tagged
isOk def isOk Boolean HasResults
issueMessages def issueMessages String HasResults
issues def issues List[Throwable] HasResults
productArity override def productArity Int
productPrefix override def productPrefix String
rejected val rejected
list of tags which are rejected for this element
Queue[Tag] Tagged
resetForExecution def resetForExecution
reset in order to be able to run the example again
Example Example
skipped def skipped
[details]
return
- the skipped messages for this example and its subexamples, executing the example if necessary
Seq[SkippedException] Example
status def status String HasResults
statusAsText def statusAsText String HasResults
subExamples def subExamples
[details]
return
- the subexamples, executing the example if necessary
Queue[Example] Example
subExs var subExs
sub-examples created inside the in method
Queue[Example] Example
tagSpec def tagSpec
[details]
return
- a description of the Tagged element showing the owned tags, the accepted and rejected tags
String Tagged
taggedComponents def taggedComponents
this method should be overriden if the Tagged element has Tagged components which should be tagged when this element is tagged
Seq[Tagged] Tagged
tags val tags
list of all tags
Queue[Tag] Tagged
thisErrors var thisErrors
errors created by Assert objects inside the in method
Queue[Throwable] Example
thisFailures var thisFailures
failures created by Assert objects inside the in method
Queue[FailureException] Example
thisSkipped var thisSkipped
skipped created by Assert objects inside the in method
Queue[SkippedException] Example

 Methods

!= final def !=(arg0 : Object) Boolean AnyRef
!= final def !=(arg0 : Any) Boolean Any
== final def ==(arg0 : Any) Boolean Any
== final def ==(arg0 : Object) Boolean AnyRef
>> def >>[T](expectations : => T)
alias for the in method
Example Example
accept def accept(t : Tag*)
Declare that this element should be accepted only if it has one of the accepted tags [details]
This method declares the same thing for the components of this element.
Tagged Tagged
acceptTag def acceptTag(s : String*)
alias for the acceptTag method
Tagged Tagged
acceptTags def acceptTags(s : String*)
alias for the accept method with strings
Tagged Tagged
addError def addError(t : Throwable)
creates and adds a new error from an exception t
Unit Example
addExample def addExample(e : Example)
add a new sub-example to this example
Unit Example
addFailure def addFailure(failure : FailureException)
creates and adds a failure exception
Unit Example
addSkipped def addSkipped(skip : SkippedException)
creates and adds a skipped exception
Unit Example
addTag def addTag(t : String)
Add one tag to this element
Tagged Tagged
addTags def addTags(t : String*)
Add one or several tags to this element
Tagged Tagged
after override def after Unit
asInstanceOf final def asInstanceOf[T0] T0 Any
before override def before Unit
clone override def clone
clone method to create a new example from this one
ExampleWithContext[S]
copyExecutionTo def copyExecutionTo[E <: Example](e : E) E Example
createExample override def createExample(desc : String, lifeCycle : ExampleLifeCycle) ExampleWithContext[S]
doTest def doTest[T](expectations : => T) Any Example
eq final def eq(arg0 : Object) Boolean AnyRef
equals override def equals(arg0 : Any) Boolean
execute override def execute(t : => Any) Any
execute def execute
execute the example, checking the expectations
Unit Example
finalize protected def finalize Unit AnyRef
getClass final def getClass Class[Object] AnyRef
hashCode override def hashCode Int
in def in(expectations : => Any)
creates a new Example object and store as an ExampleExecution object the expectations to be executed [details]
This expectations parameter is a block of code which may contain expectations with matchers. Upon execution, errors and failures will be attached to the current example by calling the addFailure and addError methods Execution will be triggered when requesting status information on that example: failures, errors, expectations number, subexamples
return
- a new Example
Example Example
isInstanceOf final def isInstanceOf[T0] Boolean Any
makeTagged def makeTagged(s : String*)
create another tagged with this new tags
Tagged Tagged
ne final def ne(arg0 : Object) Boolean AnyRef
notify final def notify Unit AnyRef
notifyAll final def notifyAll Unit AnyRef
pretty def pretty(tab : String)
[details]
return
- a user message with failures and messages, spaced with a specific tab string (used in ConsoleReport)
String Example
productElement override def productElement(arg0 : Int) Any
reject def reject(t : Tag*)
Declare that this element should be rejected if it has one of the rejected tags [details]
This method declares the same thing for the components of this element.
Tagged Tagged
rejectTag def rejectTag(s : String*)
alias for the reject method with strings
Tagged Tagged
rejectTags def rejectTags(s : String*)
alias for the reject method with several strings
Tagged Tagged
stringToTag implicit def stringToTag(s : String)
transforms a string to a Tag object
Tag Tagged
synchronized final def synchronized[T0](arg0 : T0) T0 AnyRef
tag def tag(t : String*)
Add one or several tags to this element
Tagged Tagged
tagWith def tagWith(other : Tagged)
add the tags specification from another tagged element [details]
This is used when propagating the tags from a specification to a sus for example
Tagged Tagged
toString override def toString
[details]
return
- the example description
String Example
wait final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
wait final def wait(arg0 : Long) Unit AnyRef
wait final def wait Unit AnyRef
Copyright (c) 2007-2009. All Rights Reserved.