trait
Checkpoints extends AnyRef
Value Members
-
final
def
!=(arg0: AnyRef): Boolean
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: AnyRef): Boolean
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from AnyRef
Inherited from Any
Trait providing class
Checkpoint
, which enables multiple assertions to be performed within a test, with any failures accumulated and reported together at the end of the test.Because ScalaTest uses exceptions to signal failed assertions, normally execution of a test will stop as soon as the first failed assertion is encountered. Trait
Checkpoints
provides an option when you want to continue executing the remainder of the test body, or part of it, even if an assertion has already failed in that test.To use a
Checkpoint
(once you've mixed in or imported the members of traitCheckpoints
), you first need to create one, like this:Then give the
Checkpoint
assertions to execute by passing them (via a by-name parameter) to itsapply
method, like this:Both of the above assertions will fail, but it won't be reported yet. The
Checkpoint
will execute them right away, each time itsapply
method is invoked. But it will catch theTestFailedExceptions
and save them, only reporting them later whenreportAll
is invoked. Thus, at the end of the test, you must callreportAll
, like this:This
reportAll
invocation will complete abruptly with aTestFailedException
whose message includes the message, source file, and line number of each of the checkpointed assertions that previously failed. For example:Make sure you invoke
reportAll
before the test completes, otherwise any failures that were detected by theCheckpoint
will not be reported.Note that a
Checkpoint
will catch and record for later reporting (viareportAll
) exceptions that mix inStackDepth
except forTestCanceledException
,TestRegistrationClosedException
,NotAllowedException
, andDuplicateTestNameException
. If a block of code passed to aCheckpoint
'sapply
method completes abruptly with any of theStackDepth
exceptions in the previous list, or any non-StackDepth
exception, that invocation of theapply
method will complete abruptly with the same exception immediately. Unless you putreportAll
in a finally clause and handle this case, such an unexpected exception will cause you to lose any information about assertions that failed earlier in the test and were recorded by theCheckpoint
.