Trait

org.scalatest

TestData

Related Doc: package scalatest

Permalink

trait TestData extends AnyRef

A bundle of information about the current test.

A TestData object is passed to the withFixture methods of traits Suite and fixture.Suite (both NoArgTest and OneArgTest extend TestData) and to the beforeEach and afterEach methods of trait BeforeAndAfterEach. This enables fixtures and tests to make use of the test name and configuration objects in the config map.

In ScalaTest's event model, a test may be surrounded by “scopes.” Each test and scope is associated with string of text. A test's name is a concatenation of the text of any surrounding scopes followed by the text provided with the test itself, after each text element has been trimmed and one space inserted between each component. Here's an example:

package org.scalatest.examples.freespec

import org.scalatest.FreeSpec

class SetSpec extends FreeSpec {

  "A Set" - {
    "when empty" - {
      "should have size 0" in {
        assert(Set.empty.size === 0)
      }

      "should produce NoSuchElementException when head is invoked" in {
        assertThrows[NoSuchElementException] {
          Set.empty.head
        }
      }
    }
  }
}

The above FreeSpec contains two tests, both nested inside the same two scopes. The outermost scope names the subject, A Set. The nested scope qualifies the subject with when empty. Inside that scope are the two tests. The text of the tests are:

Therefore, the names of these two tests are:

The TestData instance for the first test would contain:

Source
TestData.scala
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. TestData
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract val configMap: ConfigMap

    Permalink

    A ConfigMap containing objects that can be used to configure the fixture and test.

    A ConfigMap containing objects that can be used to configure the fixture and test.

  2. abstract val name: String

    Permalink

    The name of this test.

    The name of this test.

    See the main documentation for this trait for an explanation of the difference between name, text, and scopes.

  3. abstract val scopes: IndexedSeq[String]

    Permalink

    An immutable IndexedSeq containing the text for any "scopes" enclosing this test, in order from outermost to innermost scope.

    An immutable IndexedSeq containing the text for any "scopes" enclosing this test, in order from outermost to innermost scope.

    See the main documentation for this trait for an explanation of the difference between name, text, and scopes. If a test has no surrounding scopes, this field will contain an empty IndexedSeq.

  4. abstract val tags: Set[String]

    Permalink

    Tag names for this test.

  5. abstract val text: String

    Permalink

    The "text" for this test.

    The "text" for this test.

    See the main documentation for this trait for an explanation of the difference between name, text, and scopes. If a test has no surrounding scopes, this field will contain the same string as name.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped