org.scalatest

TestRegistrationClosedException

class TestRegistrationClosedException extends StackDepthException

Exception that indicates an action that is only allowed during a suite's test registration phase, such as registering a test to run or ignore, was attempted after registration had already closed.

In suites that register tests as functions, such as FunSuite and Spec, tests are normally registered during construction. Although it is not the usual approach, tests can also be registered after construction by invoking methods that register tests on the already constructed suite so long as run has not been invoked on that suite. As soon as run is invoked for the first time, registration of tests is "closed," meaning that any further attempts to register a test will fail (and result in an instance of this exception class being thrown). This can happen, for example, if an attempt is made to nest tests, such as in a FunSuite:

test("this test is fine") {
  test("but this nested test is not allowed") {
  }
}

This exception encapsulates information about the stack depth at which the line of code that made this attempt resides, so that information can be presented to the user that makes it quick to find the problem line of code. (In other words, the user need not scan through the stack trace to find the correct filename and line number of the offending code.)

Inherits

  1. StackDepthException
  2. StackDepth
  3. RuntimeException
  4. Exception
  5. Throwable
  6. Serializable
  7. AnyRef
  8. Any

Value Members

  1. val cause: Option[Throwable]

    An optional cause, the Throwable that caused this StackDepth exception to be thrown

    An optional cause, the Throwable that caused this StackDepth exception to be thrown.

    definition classes: StackDepthExceptionStackDepth
  2. def equals(arg0: Any): Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    The default implementations of this method is an equivalence relation:

    • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
    • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
    • It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

    If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects that are "equal" (o1.equals(o2) returns true) hash to the same Int (o1.hashCode.equals(o2.hashCode)).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    definition classes: AnyRef ⇐ Any
  3. val failedCodeFileNameAndLineNumberString: Option[String]

    A string that provides the filename and line number of the line of code that failed, suitable for presenting to a user, which is taken from this exception's StackTraceElement at the depth specified by failedCodeStackDepth

    A string that provides the filename and line number of the line of code that failed, suitable for presenting to a user, which is taken from this exception's StackTraceElement at the depth specified by failedCodeStackDepth.

    definition classes: StackDepth
  4. val failedCodeStackDepth: Int

    The depth in the stack trace of this exception at which the line of test code that failed resides

    The depth in the stack trace of this exception at which the line of test code that failed resides.

    definition classes: StackDepthExceptionStackDepth
  5. def fillInStackTrace(): Throwable

  6. def getCause(): Throwable

  7. def getLocalizedMessage(): String

  8. def getMessage(): String

  9. def getStackTrace(): Array[StackTraceElement]

  10. def hashCode(): Int

    Returns a hash code value for the object

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

    definition classes: AnyRef ⇐ Any
  11. val message: Option[String]

    An optional detail message for this StackDepth exception

    An optional detail message for this StackDepth exception.

    definition classes: StackDepthExceptionStackDepth
  12. def printStackTrace(arg0: PrintWriter): Unit

  13. def printStackTrace(arg0: PrintStream): Unit

  14. def printStackTrace(): Unit

  15. def setStackTrace(arg0: Array[StackTraceElement]): Unit

  16. def toString(): String

    Returns a string representation of the object

    Returns a string representation of the object.

    The default representation is platform dependent.

    definition classes: Throwable ⇐ AnyRef ⇐ Any

Instance constructors

  1. new TestRegistrationClosedException(message: String, failedCodeStackDepth: Int)

  2. new TestRegistrationClosedException(message: Option[String], cause: Option[Throwable], failedCodeStackDepth: Int)

  3. new TestRegistrationClosedException(arg0: Throwable)

  4. new TestRegistrationClosedException(arg0: String, arg1: Throwable)

  5. new TestRegistrationClosedException(arg0: String)

  6. new TestRegistrationClosedException()