All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scalatest.TestData.scala Maven / Gradle / Ivy

Go to download

ScalaTest is a free, open-source testing toolkit for Scala and Java programmers.

There is a newer version: 2.0.M6-SNAP4
Show newest version
package org.scalatest

/**
 * 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 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 {
 *         intercept[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: *

* *

    *
  • should have size 0
  • *
  • should produce NoSuchElementException when head is invoked
  • *
* *

* Therefore, the names of these two tests are: *

* *
    *
  • A Stack when empty should have size 0
  • *
  • A Stack when empty should produce NoSuchElementException when head is invoked
  • *
* *

* The TestData instance for the first test would contain: *

* *
    *
  • name: "A Stack when empty should have size 0"
  • *
  • scopes: collection.immutable.IndexedSeq("A Stack", "when empty")
  • *
  • text: "should have size 0"
  • *
* * @author Bill Venners * @author Chua Chee Seng */ trait TestData { /** * A Map[String, Any] containing objects that can be used * to configure the fixture and test. */ val configMap: Map[String, Any] /** * The name of this test. * *

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

*/ val name: String /** * 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. *

*/ val scopes: collection.immutable.IndexedSeq[String] /** * 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. *

*/ val text: String /** * Tag names for this test. */ val tags: Set[String] }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy