org.scalatest.events
Ordinal
class
Ordinal extends Ordered[Ordinal]
Inherited
- Hide All
- Show all
- Ordered
- Comparable
- AnyRef
- Any
Instance constructors
-
new
Ordinal(runStamp: Int)
Value Members
-
def
!=(arg0: AnyRef): Boolean
-
def
!=(arg0: Any): Boolean
-
def
##(): Int
-
def
$asInstanceOf[T0](): T0
-
def
$isInstanceOf[T0](): Boolean
-
def
<(that: Ordinal): Boolean
-
def
<=(that: Ordinal): Boolean
-
def
==(arg0: AnyRef): Boolean
-
def
==(arg0: Any): Boolean
-
def
>(that: Ordinal): Boolean
-
def
>=(that: Ordinal): Boolean
-
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
def
compare(that: Ordinal): Int
-
def
compareTo(that: Ordinal): Int
-
def
eq(arg0: AnyRef): Boolean
-
def
equals(other: Any): Boolean
-
def
finalize(): Unit
-
def
getClass(): java.lang.Class[_]
-
def
hashCode(): Int
-
def
isInstanceOf[T0]: Boolean
-
def
ne(arg0: AnyRef): Boolean
-
-
-
def
notify(): Unit
-
def
notifyAll(): Unit
-
val
runStamp: Int
-
def
synchronized[T0](arg0: T0): T0
-
def
toList: List[Int]
-
def
toString(): String
-
def
wait(): Unit
-
def
wait(arg0: Long, arg1: Int): Unit
-
def
wait(arg0: Long): Unit
Class used to specify a sequential order for events reported during a test run, so they can be arranged in that order in a report even if the events were fired in some other order during concurrent or distributed execution.
An
Ordinal
is an immutable object holding a run stamp and a sequence of stamps. The run stamp is an integer that identifies a particular run. All events reported during the same run should share the same run stamp. By contrast, each event reported during a particular run should have a different stamps sequence. One use case for the run stamp is that the initial run from ScalaTest's GUI will have run stamp 0. Subsequent reruns will have run stamps 1, 2, 3, etc., so that reports in the GUI can simply be sorted in "ordinal" order. Another use case is a set of servers used to run multiple tests simultaneously in a distributed fashion. The run stamp can be used to identify the run for which an event belongs.The stamps sequence is designed to allow a sequential order of events to be specified during concurrent execution of ScalaTest suites. ScalaTest's model for concurrent execution is that the suites that make up a run may be executed concurrently, but the tests within a single suite will be executed sequentially. In addition to tests, suites may contain nested suites. The default implementation of
execute
in classSuite
will first invokerunNestedSuites
and thenrunTests
. If noDistributor
is passed toexecute
, therunNestedSuites
method will execute the nested suites sequentially via the same thread that invokedrunNestedSuites
. As a result, suites will by default executed in depth first order when executed sequentially. If aDistributor
is passed toexecute
, therunNestedSuites
method will simply put its nested suites into theDistributor
and return. Some other threads or processes must then execute those nested suites. Given the default implementations ofexecute
andrunNestedSuites
described here, theOrdinal
will allow the events from a concurrent run to be sorted in the same depth-first order that the events from a corresponding sequential run would arrive.Each event reported during a run should be given a unique
Ordinal
. AnOrdinal
is required by allEvent
subclasses, instances of which are used to send information to thereport
function passed to aSuite
'sexecute
method. The firstOrdinal
for a run can be produced be passing a run stamp toOrdinal
's lone public constructor:The run stamp can be any integer. The
Ordinal
created in this way can be passed along with the first reported event of the run, such as aRunStarting
event. Thereafter, newOrdinal
s for the same run can be obtained by calling eithernext
ornextNewOldPair
on the previously obtainedOrdinal
. In other words, given anOrdinal
, you can obtain the nextOrdinal
by invoking one of these two "next" methods on theOrdinal
you have in hand. Before executing a newSuite
, thenextNewOldPair
method should be invoked. This will return two newOrdinal
s, one for the newSuite
about to be executed, and one for the currently executing entity (either aSuite
or some sort of test runner). At any other time, the nextOrdinal
can be obtained by simply invokingnext
on the currentOrdinal
.You can convert an
Ordinal
to aList
by invokingtoList
on it. The resultingList
will contain the run stamp as its first element, and the contents of its stamps sequence as the subsequent elements. The stamps sequence will initially be composed of a single element with the value 0. Thus,toList
invoked on thefirstOrdinal
shown above will result in:Each time
next
is invoked, the rightmost integer returned bytoList
will increment:When
nextNewOldPair
is invoked the result will be a tuple whose first element is the firstOrdinal
for the newSuite
about to be executed (for example, a nestedSuite
of the currently executingSuite
). The second element is the nextOrdinal
for the currently executingSuite
or other entity:The
toList
method of theOrdinal
for the new suite starts with the same sequence of elements as theOrdinal
from which it was created, but has one more element, a 0, appended at the end. Subsequent invocations ofnext
on this series ofOrdinal
s will increment that last element:This behavior allows events fired by
Suite
running concurrently to be reordered in a pre-determined sequence after all the events have been reported. The ordering of twoOrdinal
s can be determined by first comparing the first element of theList
s obtained by invokingtoList
on bothOrdinal
s. These values represent therunStamp
. If one run stamp is a lower number than the other, thatOrdinal
comes first. For example, anOrdinal
with a run stamp of 98 is ordered before anOrdinal
with a run stamp of 99. If the run stamps are equal, the next number in the list is inspected. As with the run stamps, anOrdinal
with a lower number is ordered before anOrdinal
with a higher number. If two corresponding elements are equal, the next pair of elements will be inspected. This will continue no down the length of theList
s until a position is found where the element values are not equal, or the end of one or both of theList
s are reached. If the twoList
s are identical all the way to the end, and bothList
s have the same lengths, then theOrdinal
s are equal. (EqualOrdinal
s will not happen if correctly used by creating a newOrdinal
for each fired event and each newSuite
.). If the twoList
s are identical all the way to the end of one, but the otherList
is longer (has more elements), then the shorter list is ordered before the longer one.As an example, here are some
Ordinal
List
forms in order:authors:
Bill Venners