Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package scalatest

    ScalaTest's main traits, classes, and other members, including members supporting ScalaTest's DSL for the Scala interpreter.

    ScalaTest's main traits, classes, and other members, including members supporting ScalaTest's DSL for the Scala interpreter.

    Definition Classes
    org
  • package concurrent

    Classes, traits, and objects related to testing asynchronous and multi-threaded behavior.

    Classes, traits, and objects related to testing asynchronous and multi-threaded behavior.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package diagrams

    A single traits and companion object that provides a assertions that draw code diagrams on failure.

    A single traits and companion object that provides a assertions that draw code diagrams on failure.

    This package is released as the scalatest-diagrams module.

    Definition Classes
    scalatest
  • package enablers

    Classes, traits, and objects for typeclasses that enable ScalaTest's DSLs.

    Classes, traits, and objects for typeclasses that enable ScalaTest's DSLs.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package events

    Classes for events sent to the org.scalatest.Reporter to report the results of running tests.

    Classes for events sent to the org.scalatest.Reporter to report the results of running tests.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package exceptions

    Classes and traits for exceptions thrown by ScalaTest.

    Classes and traits for exceptions thrown by ScalaTest.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • DiscardedEvaluationException
  • DuplicateTestNameException
  • GeneratorDrivenPropertyCheckFailedException
  • ModifiableMessage
  • ModifiablePayload
  • NotAllowedException
  • PayloadField
  • PropertyCheckFailedException
  • StackDepth
  • StackDepthException
  • TableDrivenPropertyCheckFailedException
  • TestCanceledException
  • TestFailedDueToTimeoutException
  • TestFailedException
  • TestPendingException
  • TestRegistrationClosedException
  • TimeoutField
  • package featurespec

    Classes and traits for ScalaTest's FeatureSpec style.

    Classes and traits for ScalaTest's FeatureSpec style.

    This package is released as the scalatest-featurespec module.

    Definition Classes
    scalatest
  • package fixture

    Classes and traits supporting ScalaTest's "fixture" style traits, which allow you to pass fixture objects into tests.

    Classes and traits supporting ScalaTest's "fixture" style traits, which allow you to pass fixture objects into tests.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package flatspec

    Classes and traits for ScalaTest's FlatSpec style.

    Classes and traits for ScalaTest's FlatSpec style.

    This package is released as the scalatest-flatspec module.

    Definition Classes
    scalatest
  • package freespec

    Classes and traits for ScalaTest's FreeSpec style.

    Classes and traits for ScalaTest's FreeSpec style.

    This package is released as the scalatest-freespec module.

    Definition Classes
    scalatest
  • package funspec

    Classes and traits for ScalaTest's FunSpec style.

    Classes and traits for ScalaTest's FunSpec style.

    This package is released as the scalatest-funspec module.

    Definition Classes
    scalatest
  • package funsuite

    Classes and traits for ScalaTest's FunSuite style.

    Classes and traits for ScalaTest's FunSuite style.

    This package is released as the scalatest-funsuite module.

    Definition Classes
    scalatest
  • package matchers

    Classes and traits for matchers.

    Classes and traits for matchers.

    This package is released as part of the scalatest-matchers-core module.

    Definition Classes
    scalatest
  • package path

    ScalaTest's old path package that contains deprecated aliases for path style traits.

    ScalaTest's old path package that contains deprecated aliases for path style traits.

    Definition Classes
    scalatest
  • package prop
    Definition Classes
    scalatest
  • package propspec

    Classes and traits for ScalaTest's PropSpec style.

    Classes and traits for ScalaTest's PropSpec style.

    This package is released as the scalatest-propspec module.

    Definition Classes
    scalatest
  • package refspec

    Classes and traits for ScalaTest's RefSpec style.

    Classes and traits for ScalaTest's RefSpec style.

    This package is released as the scalatest-refspec module.

    Definition Classes
    scalatest
  • package tagobjects

    Singleton-object versions of ScalaTest's built-in tags.

    Singleton-object versions of ScalaTest's built-in tags.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package tags
    Definition Classes
    scalatest
  • package time

    Classes, traits, and objects for ScalaTest's time DSL.

    Classes, traits, and objects for ScalaTest's time DSL.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package tools

    Tools for running ScalaTest.

    Tools for running ScalaTest.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package verbs

    Classes and traits that support ScalaTest DSLs.

    Classes and traits that support ScalaTest DSLs.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package words

    A deprecated package that contained support for ScalaTest DSLs.

    A deprecated package that contained support for ScalaTest DSLs.

    Definition Classes
    scalatest
  • package wordspec

    Classes and traits for ScalaTest's WordSpec style.

    Classes and traits for ScalaTest's WordSpec style.

    This package is released as the scalatest-wordspec module.

    Definition Classes
    scalatest
p

org.scalatest

exceptions

package exceptions

Classes and traits for exceptions thrown by ScalaTest.

This package is released as part of the scalatest-core module.

Source
package.scala
Linear Supertypes
AnyRef, Any

Type Members

  1. class DiscardedEvaluationException extends RuntimeException

    Exception that indicates an evaluation of a property should be discarded, because a condition required by a property was not met by the passed values.

    Exception that indicates an evaluation of a property should be discarded, because a condition required by a property was not met by the passed values.

    This exception is thrown by the whenever method defined in trait Whenever when the given condition is false. The forAll methods defined in trait PropertyChecks catch the DiscardedEvaluationException and ignore it, moving on to try the next set of parameter values it is checking th property against.

  2. class DuplicateTestNameException extends StackDepthException

    Exception that indicates an attempt was made to register a test that had the same name as a test already registered in the same suite.

    Exception that indicates an attempt was made to register a test that had the same name as a test already registered in the same suite. The purpose of this exception is to encapsulate 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.)

    Exceptions thrown

    NullArgumentException if testName is null

  3. class GeneratorDrivenPropertyCheckFailedException extends PropertyCheckFailedException

    Exception that indicates a ScalaCheck property check failed.

    Exception that indicates a ScalaCheck property check failed.

    Exceptions thrown

    NullArgumentException if any parameter is null or Some(null).

  4. trait ModifiableMessage[T <: Throwable] extends AnyRef

    Trait implemented by exception types that can modify their detail message.

    Trait implemented by exception types that can modify their detail message.

    This trait facilitates the withClue construct provided by trait Assertions. This construct enables extra information (or "clues") to be included in the detail message of a thrown exception. Although both assert and expect provide a way for a clue to be included directly, assertThrows, intercept, and ScalaTest matcher expressions do not. Here's an example of clues provided directly in assert:

    assert(1 + 1 === 3, "this is a clue")
    

    and in expect:

    expect(3, "this is a clue") { 1 + 1 }
    

    The exceptions thrown by the previous two statements will include the clue string, "this is a clue", in the exceptions detail message. To get the same clue in the detail message of an exception thrown by a failed assertThrows call requires using withClue:

    withClue("this is a clue") {
      assertThrows[IndexOutOfBoundsException] {
        "hi".charAt(-1)
      }
    }
    

    Similarly, to get a clue in the exception resulting from an exception arising out of a ScalaTest matcher expression, you need to use withClue. Here's an example:

    withClue("this is a clue") {
      1 + 1 should === (3)
    }
    

    Exception types that mix in this trait have a modifyMessage method, which returns an exception identical to itself, except with the detail message option replaced with the result of invoking the passed function, supplying the current detail message option as the lone String parameter.

  5. trait ModifiablePayload[T <: Throwable] extends AnyRef

    Trait implemented by PayloadField exception types that can modify their payload.

    Trait implemented by PayloadField exception types that can modify their payload.

    This trait facilitates the withPayload construct provided by trait Payloads. This construct enables a payload object (or modified payload object) to be included as the payload of a thrown exception. The payload can then be included in the ScalaTest event that results from that exception. For example, the payload included in a TestFailedException will be included as the payload of the resulting TestFailed event. Here's an example in which a GUI snapshot is included as a payload when a test fails:

    withPayload(generateGUISnapshot()) {
      1 + 1 should === (3)
    }
    

    Exception types that mix in this trait have a modifyPayload method, which returns an exception identical to itself, except with the payload option replaced with the result of invoking the passed function, supplying the current payload option as the lone Option[Any] parameter.

  6. class NotAllowedException extends StackDepthException

    Exception that indicates something was attempted in test code that is not allowed.

    Exception that indicates something was attempted in test code that is not allowed. For example, in a FeatureSpec, it is not allowed to nest a feature clause inside another feature clause. If this is attempted, the construction of that suite will fail with a NotAllowedException.

    Exceptions thrown

    NullArgumentException if either message or failedCodeStackDepthFun is null

  7. trait PayloadField extends AnyRef

    Trait implemented by exception types that carry an optional payload.

    Trait implemented by exception types that carry an optional payload.

    Many ScalaTest events include an optional "payload" field that can be used to pass information to a custom reporter. This trait facilitates such customization, by allowing test code to include a payload in an exception (such as TestFailedException). ScalaTest looks for this trait and fires any payloads it finds in the relevant ScalaTest event stimulated by the exception, such as a TestFailed event stimulated by a TestFailedException. (Although in its initial release there is only two subclasses of PayloadField in ScalaTest, TestFailedException and TestCanceledException, in future version of ScalaTest, there could be more)

    For an example of how payloads could be used, see the documentation for trait Payloads.

  8. abstract class PropertyCheckFailedException extends TestFailedException

    Exception that indicates a property check failed.

    Exception that indicates a property check failed.

    Exceptions thrown

    NullArgumentException if any parameter is null or Some(null).

  9. trait StackDepth extends AnyRef

    Trait that encapsulates the information required of an exception thrown by ScalaTest's assertions and matchers, which includes a stack depth at which the failing line of test code resides.

    Trait that encapsulates the information required of an exception thrown by ScalaTest's assertions and matchers, which includes a stack depth at which the failing line of test code resides.

    This trait exists so that it can be mixed into two exception superclasses, StackDepthException, from which extend several exceptions that do not depend on JUnit, and JUnitTestFailedError, which does depend on JUnit. The latter, which requires JUnit be in the classpath, ensures failed ScalaTest assertions are reported as "failures," not "errors," by JUnit.

  10. abstract class StackDepthException extends RuntimeException with StackDepth

    Exception class that encapsulates information about the stack depth at which the line of code that failed resides, so that information can be presented to the user that makes it quick to find the failing line of code.

    Exception class that encapsulates information about the stack depth at which the line of code that failed resides, so that information can be presented to the user that makes it quick to find the failing 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 problem code.) Having a stack depth is more useful in a testing environment in which test failures are implemented as thrown exceptions, as is the case in ScalaTest's built-in suite traits.

    Exceptions thrown

    NullArgumentException if either messageFun, cause or failedCodeStackDepthFun is null, or Some(null).

  11. class TableDrivenPropertyCheckFailedException extends PropertyCheckFailedException

    Exception that indicates a table-driven property check failed.

    Exception that indicates a table-driven property check failed.

    For an introduction to using tables, see the documentation for trait TableDrivenPropertyChecks.

    Exceptions thrown

    NullArgumentException if any parameter is null or Some(null).

  12. class TestCanceledException extends StackDepthException with ModifiableMessage[TestCanceledException] with PayloadField with ModifiablePayload[TestCanceledException]

    Exception thrown to indicate a test has been canceled.

    Exception thrown to indicate a test has been canceled.

    A canceled test is one that is unable to run because a needed dependency, such as an external database, is missing.

    Canceled tests are ones that complete abruptly with a TestCanceledException after starting.

  13. class TestFailedDueToTimeoutException extends TestFailedException with TimeoutField

    Subclass of TestFailedException representing tests that failed because of a timeout.

    Subclass of TestFailedException representing tests that failed because of a timeout.

    This exception is thrown by the failAfter method of trait Timeouts, the eventually method of trait Eventually, and the await methods of trait AsyncAssertions.

    Exceptions thrown

    NullArgumentException if either messageFun, cause or failedCodeStackDepthFun is null, or Some(null).

  14. class TestFailedException extends StackDepthException with ModifiableMessage[TestFailedException] with PayloadField with ModifiablePayload[TestFailedException]

    Exception that indicates a test failed.

    Exception that indicates a test failed.

    One purpose of this exception is to encapsulate information about the stack depth at which the line of test code that failed resides, so that information can be presented to the user that makes it quick to find the failing line of test code. (In other words, the user need not scan through the stack trace to find the correct filename and line number of the failing test.)

    Another purpose of this exception is to encapsulate a payload, an object to be included in a TestFailed event as its payload, so it can be consumed by a custom reporter that understands the payload. For example, tests could take a screen shot image of a GUI when a test fails, and include that as a payload. A custom reporter could listen for such payloads and display the screen shots to the user.

    Exceptions thrown

    NullArgumentException if either messageFun, cause or failedCodeStackDepthFun is null, or Some(null).

  15. class TestPendingException extends RuntimeException

    Exception thrown to indicate a test is pending.

    Exception thrown to indicate a test is pending.

    A pending test is one that has been given a name but is not yet implemented. The purpose of pending tests is to facilitate a style of testing in which documentation of behavior is sketched out before tests are written to verify that behavior (and often, the before the behavior of the system being tested is itself implemented). Such sketches form a kind of specification of what tests and functionality to implement later.

    To support this style of testing, a test can be given a name that specifies one bit of behavior required by the system being tested. The test can also include some code that sends more information about the behavior to the reporter when the tests run. At the end of the test, it can call method pending, which will cause it to complete abruptly with TestPendingException. Because tests in ScalaTest can be designated as pending with TestPendingException, both the test name and any information sent to the reporter when running the test can appear in the report of a test run. (In other words, the code of a pending test is executed just like any other test.) However, because the test completes abruptly with TestPendingException, the test will be reported as pending, to indicate the actual test, and possibly the functionality, has not yet been implemented.

  16. 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.

    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 FunSpec, 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.)

    Exceptions thrown

    NullArgumentException if either message or failedCodeStackDepthFun is null

  17. trait TimeoutField extends AnyRef

    Trait mixed into exceptions thrown due to a timeout, which offers a timeout field providing a Span representing the timeout that expired.

    Trait mixed into exceptions thrown due to a timeout, which offers a timeout field providing a Span representing the timeout that expired.

    This trait is used by trait TimeLimitedTests to detect exceptions thrown because of timeouts, and for such exceptions, to modify the message to more clearly indicate a test timed out. (Although in its initial release there is only one subclass of TimeoutField in ScalaTest, TestFailedDueToTimeoutException, in future version of ScalaTest, there could be more)

Inherited from AnyRef

Inherited from Any

Ungrouped