Packages

package prop

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

Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. prop
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait Configuration extends AnyRef

    Trait providing methods and classes used to configure property checks provided by the the forAll methods of trait GeneratorDrivenPropertyChecks (for ScalaTest-style property checks) and the check methods of trait Checkers (for ScalaCheck-style property checks).

  2. trait TableDrivenPropertyChecks extends Whenever with Tables

    Trait containing methods that faciliate property checks against tables of data.

    Trait containing methods that faciliate property checks against tables of data.

    This trait contains one exists, forAll, and forEvery method for each TableForN class, TableFor1 through TableFor22, which allow properties to be checked against the rows of a table. It also contains a wherever method that can be used to indicate a property need only hold whenever some condition is true.

    For an example of trait TableDrivenPropertyChecks in action, imagine you want to test this Fraction class:

    class Fraction(n: Int, d: Int) {
    
    require(d != 0) require(d != Integer.MIN_VALUE) require(n != Integer.MIN_VALUE)
    val numer = if (d < 0) -1 * n else n val denom = d.abs
    override def toString = numer + " / " + denom }

    TableDrivenPropertyChecks allows you to create tables with between 1 and 22 columns and any number of rows. You create a table by passing tuples to one of the factory methods of object Table. Each tuple must have the same arity (number of members). The first tuple you pass must all be strings, because it define names for the columns. Subsequent tuples define the data. After the initial tuple that contains string column names, all tuples must have the same type. For example, if the first tuple after the column names contains two Ints, all subsequent tuples must contain two Int (i.e., have type Tuple2[Int, Int]).

    To test the behavior of Fraction, you could create a table of numerators and denominators to pass to the constructor of the Fraction class using one of the apply factory methods declared in Table, like this:

    import org.scalatest.prop.TableDrivenPropertyChecks._
    
    val fractions = Table( ("n", "d"), // First tuple defines column names ( 1, 2), // Subsequent tuples define the data ( -1, 2), ( 1, -2), ( -1, -2), ( 3, 1), ( -3, 1), ( -3, 0), ( 3, -1), ( 3, Integer.MIN_VALUE), (Integer.MIN_VALUE, 3), ( -3, -1) )

    You could then check a property against each row of the table using a forAll method, like this:

    import org.scalatest.Matchers._
    
    forAll (fractions) { (n: Int, d: Int) =>
    whenever (d != 0 && d != Integer.MIN_VALUE && n != Integer.MIN_VALUE) {
    val f = new Fraction(n, d)
    if (n < 0 && d < 0 || n > 0 && d > 0) f.numer should be > 0 else if (n != 0) f.numer should be < 0 else f.numer should be === 0
    f.denom should be > 0 } }

    Trait TableDrivenPropertyChecks provides 22 overloaded exists, forAll, and forEvery methods that allow you to check properties using the data provided by a table. Each exists, forAll, and forEvery method takes two parameter lists. The first parameter list is a table. The second parameter list is a function whose argument types and number matches that of the tuples in the table. For example, if the tuples in the table supplied to forAll each contain an Int, a String, and a List[Char], then the function supplied to forAll must take 3 parameters, an Int, a String, and a List[Char]. The forAll method will pass each row of data to the function, and generate a TableDrivenPropertyCheckFailedException if the function completes abruptly for any row of data with any exception that would normally cause a test to fail in ScalaTest other than DiscardedEvaluationException. A DiscardedEvaluationException, which is thrown by the whenever method (also defined in this trait) to indicate a condition required by the property function is not met by a row of passed data, will simply cause forAll to skip that row of data.

    The full list of table methods are:

    • exists - succeeds if the assertion holds true for at least one element
    • forAll - succeeds if the assertion holds true for every element
    • forEvery - same as forAll, but lists all failing elements if it fails (whereas forAll just reports the first failing element) and throws TestFailedException with the first failed check as the cause.

    Testing stateful functions

    One way to use a table with one column is to test subsequent return values of a stateful function. Imagine, for example, you had an object named FiboGen whose next method returned the next fibonacci number, where next means the next number in the series following the number previously returned by next. So the first time next was called, it would return 0. The next time it was called it would return 1. Then 1. Then 2. Then 3, and so on. FiboGen would need to maintain state, because it has to remember where it is in the series. In such a situation, you could create a TableFor1 (a table with one column, which you could alternatively think of as one row), in which each row represents the next value you expect.

    val first14FiboNums =
      Table("n", 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233)
    

    Then in your forAll simply call the function and compare it with the expected return value, like this:

    forAll (first14FiboNums) { n =>
      FiboGen.next should equal (n)
    }
    

    Testing mutable objects

    If you need to test a mutable object, one way you can use tables is to specify state transitions in a table. For example, imagine you wanted to test this mutable Counter class:

    class Counter {
      private var c = 0
      def reset() { c = 0 }
      def click() { c += 1 }
      def enter(n: Int) { c = n }
      def count = c
    }
    

    A Counter keeps track of how many times its click method is called. The count starts out at zero and increments with each click invocation. You can also set the count to a specific value by calling enter and passing the value in. And the reset method returns the count back to zero. You could define the actions that initiate state transitions with case classes, like this:

    abstract class Action
    case object Start extends Action
    case object Click extends Action
    case class Enter(n: Int) extends Action
    

    Given these actions, you could define a state-transition table like this:

    val stateTransitions =
      Table(
        ("action", "expectedCount"),
        (Start,    0),
        (Click,    1),
        (Click,    2),
        (Click,    3),
        (Enter(5), 5),
        (Click,    6),
        (Enter(1), 1),
        (Click,    2),
        (Click,    3)
      )
    

    To use this in a test, simply do a pattern match inside the function you pass to forAll. Make a pattern for each action, and have the body perform that action when there's a match. Then check that the actual value equals the expected value:

    val counter = new Counter
    forAll (stateTransitions) { (action, expectedCount) =>
      action match {
        case Start => counter.reset()
        case Click => counter.click()
        case Enter(n) => counter.enter(n)
      }
      counter.count should equal (expectedCount)
    }
    

    Testing invalid argument combinations

    A table-driven property check can also be helpful to ensure that the proper exception is thrown when invalid data is passed to a method or constructor. For example, the Fraction constructor shown above should throw IllegalArgumentException if Integer.MIN_VALUE is passed for either the numerator or denominator, or zero is passed for the denominator. This yields the following five combinations of invalid data:

    nd
    Integer.MIN_VALUEInteger.MIN_VALUE
    a valid valueInteger.MIN_VALUE
    Integer.MIN_VALUEa valid value
    Integer.MIN_VALUEzero
    a valid valuezero

    You can express these combinations in a table:

    val invalidCombos =
      Table(
        ("n",               "d"),
        (Integer.MIN_VALUE, Integer.MIN_VALUE),
        (1,                 Integer.MIN_VALUE),
        (Integer.MIN_VALUE, 1),
        (Integer.MIN_VALUE, 0),
        (1,                 0)
      )
    

    Given this table, you could check that all invalid combinations produce IllegalArgumentException, like this:

    forAll (invalidCombos) { (n: Int, d: Int) =>
      evaluating {
        new Fraction(n, d)
      } should produce [IllegalArgumentException]
    }
    

  3. class TableFor1[A] extends IndexedSeq[A] with IndexedSeqLike[A, TableFor1[A]]

    A table with 1 column.

    A table with 1 column.

    For an overview of using tables, see the documentation for trait TableDrivenPropertyChecks.

    This table is a sequence of objects, where each object represents one row of the (one-column) table. This table also carries with it a heading tuple that gives a string name to the lone column of the table.

    A handy way to create a TableFor1 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        "a",
          0,
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9
      )
    

    Because you supplied a list of non-tuple objects, the type you'll get back will be a TableFor1.

    The table provides an apply method that takes a function with a parameter list that matches the type of the objects contained in this table. The apply method will invoke the function with the object in each row passed as the lone argument, in ascending order by index. (I.e., the zeroth object is checked first, then the object with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor1 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor1, passing in the property check function. Here's an example:

    forAll (examples) { (a) =>
      a should equal (a * 1)
    }
    

    Because TableFor1 is a Seq[(A)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

    One other way to use a TableFor1 is to test subsequent return values of a stateful function. Imagine, for example, you had an object named FiboGen whose next method returned the next fibonacci number, where next means the next number in the series following the number previously returned by next. So the first time next was called, it would return 0. The next time it was called it would return 1. Then 1. Then 2. Then 3, and so on. FiboGen would need to be stateful, because it has to remember where it is in the series. In such a situation, you could create a TableFor1 (a table with one column, which you could alternatively think of as one row), in which each row represents the next value you expect.

    val first14FiboNums =
      Table("n", 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233)
    

    Then in your forAll simply call the function and compare it with the expected return value, like this:

    forAll (first14FiboNums) { n =>
      FiboGen.next should equal (n)
    }
    

  4. class TableFor10[A, B, C, D, E, F, G, H, I, J] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J), TableFor10[A, B, C, D, E, F, G, H, I, J]]

    A table with 10 columns.

    A table with 10 columns.

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

    This table is a sequence of Tuple10 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor10 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 10 members in each tuple, the type you'll get back will be a TableFor10.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor10 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor10, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j) =>
      a + b + c + d + e + f + g + h + i + j should equal (a * 10)
    }
    

    Because TableFor10 is a Seq[(A, B, C, D, E, F, G, H, I, J)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  5. class TableFor11[A, B, C, D, E, F, G, H, I, J, K] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K), TableFor11[A, B, C, D, E, F, G, H, I, J, K]]

    A table with 11 columns.

    A table with 11 columns.

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

    This table is a sequence of Tuple11 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor11 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 11 members in each tuple, the type you'll get back will be a TableFor11.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor11 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor11, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k) =>
      a + b + c + d + e + f + g + h + i + j + k should equal (a * 11)
    }
    

    Because TableFor11 is a Seq[(A, B, C, D, E, F, G, H, I, J, K)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  6. class TableFor12[A, B, C, D, E, F, G, H, I, J, K, L] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L), TableFor12[A, B, C, D, E, F, G, H, I, J, K, L]]

    A table with 12 columns.

    A table with 12 columns.

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

    This table is a sequence of Tuple12 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor12 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 12 members in each tuple, the type you'll get back will be a TableFor12.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor12 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor12, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l) =>
      a + b + c + d + e + f + g + h + i + j + k + l should equal (a * 12)
    }
    

    Because TableFor12 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  7. class TableFor13[A, B, C, D, E, F, G, H, I, J, K, L, M] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M), TableFor13[A, B, C, D, E, F, G, H, I, J, K, L, M]]

    A table with 13 columns.

    A table with 13 columns.

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

    This table is a sequence of Tuple13 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor13 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 13 members in each tuple, the type you'll get back will be a TableFor13.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor13 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor13, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m should equal (a * 13)
    }
    

    Because TableFor13 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  8. class TableFor14[A, B, C, D, E, F, G, H, I, J, K, L, M, N] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M, N), TableFor14[A, B, C, D, E, F, G, H, I, J, K, L, M, N]]

    A table with 14 columns.

    A table with 14 columns.

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

    This table is a sequence of Tuple14 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor14 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 14 members in each tuple, the type you'll get back will be a TableFor14.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor14 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor14, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m + n should equal (a * 14)
    }
    

    Because TableFor14 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  9. class TableFor15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O), TableFor15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]]

    A table with 15 columns.

    A table with 15 columns.

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

    This table is a sequence of Tuple15 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor15 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 15 members in each tuple, the type you'll get back will be a TableFor15.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor15 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor15, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m + n + o should equal (a * 15)
    }
    

    Because TableFor15 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  10. class TableFor16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P), TableFor16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]]

    A table with 16 columns.

    A table with 16 columns.

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

    This table is a sequence of Tuple16 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor16 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 16 members in each tuple, the type you'll get back will be a TableFor16.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor16 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor16, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p should equal (a * 16)
    }
    

    Because TableFor16 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  11. class TableFor17[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q), TableFor17[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]]

    A table with 17 columns.

    A table with 17 columns.

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

    This table is a sequence of Tuple17 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor17 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 17 members in each tuple, the type you'll get back will be a TableFor17.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor17 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor17, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q should equal (a * 17)
    }
    

    Because TableFor17 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  12. class TableFor18[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R), TableFor18[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R]]

    A table with 18 columns.

    A table with 18 columns.

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

    This table is a sequence of Tuple18 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor18 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 18 members in each tuple, the type you'll get back will be a TableFor18.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor18 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor18, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r should equal (a * 18)
    }
    

    Because TableFor18 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  13. class TableFor19[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S), TableFor19[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S]]

    A table with 19 columns.

    A table with 19 columns.

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

    This table is a sequence of Tuple19 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor19 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 19 members in each tuple, the type you'll get back will be a TableFor19.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor19 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor19, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s should equal (a * 19)
    }
    

    Because TableFor19 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  14. class TableFor2[A, B] extends IndexedSeq[(A, B)] with IndexedSeqLike[(A, B), TableFor2[A, B]]

    A table with 2 columns.

    A table with 2 columns.

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

    This table is a sequence of Tuple2 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor2 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b"),
     *     (  0,   0),
        (  1,   1),
        (  2,   2),
        (  3,   3),
        (  4,   4),
        (  5,   5),
        (  6,   6),
        (  7,   7),
        (  8,   8),
        (  9,   9)
      )
    

    Because you supplied 2 members in each tuple, the type you'll get back will be a TableFor2.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor2 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor2, passing in the property check function. Here's an example:

    forAll (examples) { (a, b) =>
      a + b should equal (a * 2)
    }
    

    Because TableFor2 is a Seq[(A, B)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  15. class TableFor20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T), TableFor20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T]]

    A table with 20 columns.

    A table with 20 columns.

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

    This table is a sequence of Tuple20 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor20 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 20 members in each tuple, the type you'll get back will be a TableFor20.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor20 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor20, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t should equal (a * 20)
    }
    

    Because TableFor20 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  16. class TableFor21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U), TableFor21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U]]

    A table with 21 columns.

    A table with 21 columns.

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

    This table is a sequence of Tuple21 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor21 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 21 members in each tuple, the type you'll get back will be a TableFor21.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor21 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor21, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u should equal (a * 21)
    }
    

    Because TableFor21 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  17. class TableFor22[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] extends IndexedSeq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V), TableFor22[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V]]

    A table with 22 columns.

    A table with 22 columns.

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

    This table is a sequence of Tuple22 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor22 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 22 members in each tuple, the type you'll get back will be a TableFor22.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor22 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor22, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) =>
      a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u + v should equal (a * 22)
    }
    

    Because TableFor22 is a Seq[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  18. class TableFor3[A, B, C] extends IndexedSeq[(A, B, C)] with IndexedSeqLike[(A, B, C), TableFor3[A, B, C]]

    A table with 3 columns.

    A table with 3 columns.

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

    This table is a sequence of Tuple3 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor3 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c"),
     *     (  0,   0,   0),
        (  1,   1,   1),
        (  2,   2,   2),
        (  3,   3,   3),
        (  4,   4,   4),
        (  5,   5,   5),
        (  6,   6,   6),
        (  7,   7,   7),
        (  8,   8,   8),
        (  9,   9,   9)
      )
    

    Because you supplied 3 members in each tuple, the type you'll get back will be a TableFor3.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor3 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor3, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c) =>
      a + b + c should equal (a * 3)
    }
    

    Because TableFor3 is a Seq[(A, B, C)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  19. class TableFor4[A, B, C, D] extends IndexedSeq[(A, B, C, D)] with IndexedSeqLike[(A, B, C, D), TableFor4[A, B, C, D]]

    A table with 4 columns.

    A table with 4 columns.

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

    This table is a sequence of Tuple4 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor4 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d"),
     *     (  0,   0,   0,   0),
        (  1,   1,   1,   1),
        (  2,   2,   2,   2),
        (  3,   3,   3,   3),
        (  4,   4,   4,   4),
        (  5,   5,   5,   5),
        (  6,   6,   6,   6),
        (  7,   7,   7,   7),
        (  8,   8,   8,   8),
        (  9,   9,   9,   9)
      )
    

    Because you supplied 4 members in each tuple, the type you'll get back will be a TableFor4.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor4 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor4, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d) =>
      a + b + c + d should equal (a * 4)
    }
    

    Because TableFor4 is a Seq[(A, B, C, D)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  20. class TableFor5[A, B, C, D, E] extends IndexedSeq[(A, B, C, D, E)] with IndexedSeqLike[(A, B, C, D, E), TableFor5[A, B, C, D, E]]

    A table with 5 columns.

    A table with 5 columns.

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

    This table is a sequence of Tuple5 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor5 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e"),
     *     (  0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9)
      )
    

    Because you supplied 5 members in each tuple, the type you'll get back will be a TableFor5.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor5 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor5, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e) =>
      a + b + c + d + e should equal (a * 5)
    }
    

    Because TableFor5 is a Seq[(A, B, C, D, E)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  21. class TableFor6[A, B, C, D, E, F] extends IndexedSeq[(A, B, C, D, E, F)] with IndexedSeqLike[(A, B, C, D, E, F), TableFor6[A, B, C, D, E, F]]

    A table with 6 columns.

    A table with 6 columns.

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

    This table is a sequence of Tuple6 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor6 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f"),
     *     (  0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 6 members in each tuple, the type you'll get back will be a TableFor6.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor6 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor6, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f) =>
      a + b + c + d + e + f should equal (a * 6)
    }
    

    Because TableFor6 is a Seq[(A, B, C, D, E, F)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  22. class TableFor7[A, B, C, D, E, F, G] extends IndexedSeq[(A, B, C, D, E, F, G)] with IndexedSeqLike[(A, B, C, D, E, F, G), TableFor7[A, B, C, D, E, F, G]]

    A table with 7 columns.

    A table with 7 columns.

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

    This table is a sequence of Tuple7 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor7 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g"),
     *     (  0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 7 members in each tuple, the type you'll get back will be a TableFor7.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor7 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor7, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g) =>
      a + b + c + d + e + f + g should equal (a * 7)
    }
    

    Because TableFor7 is a Seq[(A, B, C, D, E, F, G)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  23. class TableFor8[A, B, C, D, E, F, G, H] extends IndexedSeq[(A, B, C, D, E, F, G, H)] with IndexedSeqLike[(A, B, C, D, E, F, G, H), TableFor8[A, B, C, D, E, F, G, H]]

    A table with 8 columns.

    A table with 8 columns.

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

    This table is a sequence of Tuple8 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor8 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 8 members in each tuple, the type you'll get back will be a TableFor8.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor8 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor8, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h) =>
      a + b + c + d + e + f + g + h should equal (a * 8)
    }
    

    Because TableFor8 is a Seq[(A, B, C, D, E, F, G, H)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  24. class TableFor9[A, B, C, D, E, F, G, H, I] extends IndexedSeq[(A, B, C, D, E, F, G, H, I)] with IndexedSeqLike[(A, B, C, D, E, F, G, H, I), TableFor9[A, B, C, D, E, F, G, H, I]]

    A table with 9 columns.

    A table with 9 columns.

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

    This table is a sequence of Tuple9 objects, where each tuple represents one row of the table. The first element of each tuple comprise the first column of the table, the second element of each tuple comprise the second column, and so on. This table also carries with it a heading tuple that gives string names to the columns of the table.

    A handy way to create a TableFor9 is via an apply factory method in the Table singleton object provided by the Tables trait. Here's an example:

    val examples =
      Table(
        ("a", "b", "c", "d", "e", "f", "g", "h", "i"),
     *     (  0,   0,   0,   0,   0,   0,   0,   0,   0),
        (  1,   1,   1,   1,   1,   1,   1,   1,   1),
        (  2,   2,   2,   2,   2,   2,   2,   2,   2),
        (  3,   3,   3,   3,   3,   3,   3,   3,   3),
        (  4,   4,   4,   4,   4,   4,   4,   4,   4),
        (  5,   5,   5,   5,   5,   5,   5,   5,   5),
        (  6,   6,   6,   6,   6,   6,   6,   6,   6),
        (  7,   7,   7,   7,   7,   7,   7,   7,   7),
        (  8,   8,   8,   8,   8,   8,   8,   8,   8),
        (  9,   9,   9,   9,   9,   9,   9,   9,   9)
      )
    

    Because you supplied 9 members in each tuple, the type you'll get back will be a TableFor9.

    The table provides an apply method that takes a function with a parameter list that matches the types and arity of the tuples contained in this table. The apply method will invoke the function with the members of each row tuple passed as arguments, in ascending order by index. (I.e., the zeroth tuple is checked first, then the tuple with index 1, then index 2, and so on until all the rows have been checked (or until a failure occurs). The function represents a property of the code under test that should succeed for every row of the table. If the function returns normally, that indicates the property check succeeded for that row. If the function completes abruptly with an exception, that indicates the property check failed and the apply method will complete abruptly with a TableDrivenPropertyCheckFailedException that wraps the exception thrown by the supplied property function.

    The usual way you'd invoke the apply method that checks a property is via a forAll method provided by trait TableDrivenPropertyChecks. The forAll method takes a TableFor9 as its first argument, then in a curried argument list takes the property check function. It invokes apply on the TableFor9, passing in the property check function. Here's an example:

    forAll (examples) { (a, b, c, d, e, f, g, h, i) =>
      a + b + c + d + e + f + g + h + i should equal (a * 9)
    }
    

    Because TableFor9 is a Seq[(A, B, C, D, E, F, G, H, I)], you can use it as a Seq. For example, here's how you could get a sequence of Outcomes for each row of the table, indicating whether a property check succeeded or failed on each row of the table:

    for (row <- examples) yield {
      outcomeOf { row._1 should not equal (7) }
    }
    

    Note: the outcomeOf method, contained in the OutcomeOf trait, will execute the supplied code (a by-name parameter) and transform it to an Outcome. If no exception is thrown by the code, outcomeOf will result in a Succeeded, indicating the "property check" succeeded. If the supplied code completes abruptly in an exception that would normally cause a test to fail, outcomeOf will result in in a Failed instance containing that exception. For example, the previous for expression would give you:

    Vector(Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded, Succeeded,
        Failed(org.scalatest.TestFailedException: 7 equaled 7), Succeeded, Succeeded)
    

    This shows that all the property checks succeeded, except for the one at index 7.

  25. trait Tables extends AnyRef

    Trait containing the Table object, which offers one apply factory method for each TableForN class, TableFor1 through TableFor22.

    Trait containing the Table object, which offers one apply factory method for each TableForN class, TableFor1 through TableFor22.

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

  26. trait Whenever extends AnyRef

    Trait that contains the whenever clause that can be used in table- or generator-driven property checks.

  27. trait Checkers extends ScalaCheckConfiguration

    Trait that contains several “check” methods that perform ScalaCheck property checks.

    Trait that contains several “check” methods that perform ScalaCheck property checks. If ScalaCheck finds a test case for which a property doesn't hold, the problem will be reported as a ScalaTest test failure.

    To use ScalaCheck, you specify properties and, in some cases, generators that generate test data. You need not always create generators, because ScalaCheck provides many default generators for you that can be used in many situations. ScalaCheck will use the generators to generate test data and with that data run tests that check that the property holds. Property-based tests can, therefore, give you a lot more testing for a lot less code than assertion-based tests. Here's an example of using ScalaCheck from a JUnitSuite:

    import org.scalatest.junit.JUnitSuite
    import org.scalatest.prop.Checkers
    import org.scalacheck.Arbitrary._
    import org.scalacheck.Prop._
    
    class MySuite extends JUnitSuite with Checkers { @Test def testConcat() { check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size) } }

    The check method, defined in Checkers, makes it easy to write property-based tests inside ScalaTest, JUnit, and TestNG test suites. This example specifies a property that List's ::: method should obey. ScalaCheck properties are expressed as function values that take the required test data as parameters. ScalaCheck will generate test data using generators and repeatedly pass generated data to the function. In this case, the test data is composed of integer lists named a and b. Inside the body of the function, you see:

    a.size + b.size == (a ::: b).size
    

    The property in this case is a Boolean expression that will yield true if the size of the concatenated list is equal to the size of each individual list added together. With this small amount of code, ScalaCheck will generate possibly hundreds of value pairs for a and b and test each pair, looking for a pair of integers for which the property doesn't hold. If the property holds true for every value ScalaCheck tries, check returns normally. Otherwise, check will complete abruptly with a TestFailedException that contains information about the failure, including the values that cause the property to be false.

    For more information on using ScalaCheck properties, see the documentation for ScalaCheck, which is available from http://code.google.com/p/scalacheck/.

    To execute a suite that mixes in Checkers with ScalaTest's Runner, you must include ScalaCheck's jar file on the class path or runpath.

    Property check configuration

    The property checks performed by the check methods of this trait can be flexibly configured via the services provided by supertrait Configuration. The five configuration parameters for property checks along with their default values and meanings are described in the following table:

    Configuration Parameter Default Value Meaning
    minSuccessful 100 the minimum number of successful property evaluations required for the property to pass
    maxDiscarded 500 the maximum number of discarded property evaluations allowed during a property check
    minSize 0 the minimum size parameter to provide to ScalaCheck, which it will use when generating objects for which size matters (such as strings or lists)
    maxSize 100 the maximum size parameter to provide to ScalaCheck, which it will use when generating objects for which size matters (such as strings or lists)
    workers 1 specifies the number of worker threads to use during property evaluation

    The check methods of trait Checkers each take a PropertyCheckConfiguration object as an implicit parameter. This object provides values for each of the five configuration parameters. Trait Configuration provides an implicit val named generatorDrivenConfig with each configuration parameter set to its default value. If you want to set one or more configuration parameters to a different value for all property checks in a suite you can override this val (or hide it, for example, if you are importing the members of the Checkers companion object rather than mixing in the trait.) For example, if you want all parameters at their defaults except for minSize and maxSize, you can override generatorDrivenConfig, like this:

    implicit override val generatorDrivenConfig =
      PropertyCheckConfiguration(minSize = 10, sizeRange = 10)
    

    Or, if hide it by declaring a variable of the same name in whatever scope you want the changed values to be in effect:

    implicit val generatorDrivenConfig =
      PropertyCheckConfiguration(minSize = 10, sizeRange = 10)
    

    In addition to taking a PropertyCheckConfiguration object as an implicit parameter, the check methods of trait Checkers also take a variable length argument list of PropertyCheckConfigParam objects that you can use to override the values provided by the implicit PropertyCheckConfiguration for a single check invocation. You place these configuration settings after the property or property function, For example, if you want to set minSuccessful to 500 for just one particular check invocation, you can do so like this:

    check((n: Int) => n + 0 == n, minSuccessful(500))
    

    This invocation of check will use 500 for minSuccessful and whatever values are specified by the implicitly passed PropertyCheckConfiguration object for the other configuration parameters. If you want to set multiple configuration parameters in this way, just list them separated by commas:

    check((n: Int) => n + 0 == n, minSuccessful(500), maxDiscardedFactor(0.6))
    

    The previous configuration approach works the same in Checkers as it does in GeneratorDrivenPropertyChecks. Trait Checkers also provides one check method that takes an org.scalacheck.Test.Parameters object, in case you want to configure ScalaCheck that way.

    import org.scalacheck.Prop
    import org.scalacheck.Test.Parameters
    import org.scalatest.prop.Checkers._
    
    check(Prop.forAll((n: Int) => n + 0 == n), Parameters.Default { override val minSuccessfulTests = 5 })

    For more information, see the documentation for supertrait Configuration.

    Annotations
    @deprecated
    Deprecated

    Checkers has been moved from org.scalatest.prop to org.scalatestplus.scalacheck. Please update your imports, as this deprecated type alias will be removed in a future version of ScalaTest.

  28. trait GeneratorDrivenPropertyChecks extends Whenever with ScalaCheckConfiguration

    Trait containing methods that faciliate property checks against generated data using ScalaCheck.

    Trait containing methods that faciliate property checks against generated data using ScalaCheck.

    This trait contains forAll methods that provide various ways to check properties using generated data. Use of this trait requires that ScalaCheck be on the class path when you compile and run your tests. It also contains a wherever method that can be used to indicate a property need only hold whenever some condition is true.

    For an example of trait GeneratorDrivenPropertyChecks in action, imagine you want to test this Fraction class:

    class Fraction(n: Int, d: Int) {
    
    require(d != 0) require(d != Integer.MIN_VALUE) require(n != Integer.MIN_VALUE)
    val numer = if (d < 0) -1 * n else n val denom = d.abs
    override def toString = numer + " / " + denom }

    To test the behavior of Fraction, you could mix in or import the members of GeneratorDrivenPropertyChecks (and Matchers) and check a property using a forAll method, like this:

    forAll { (n: Int, d: Int) =>
    
    whenever (d != 0 && d != Integer.MIN_VALUE && n != Integer.MIN_VALUE) {
    val f = new Fraction(n, d)
    if (n < 0 && d < 0 || n > 0 && d > 0) f.numer should be > 0 else if (n != 0) f.numer should be < 0 else f.numer should be === 0
    f.denom should be > 0 } }

    Trait GeneratorDrivenPropertyChecks provides overloaded forAll methods that allow you to check properties using the data provided by a ScalaCheck generator. The simplest form of forAll method takes two parameter lists, the second of which is implicit. The first parameter list is a "property" function with one to six parameters. An implicit Arbitrary generator and Shrink object needs to be supplied for The forAll method will pass each row of data to each parameter type. ScalaCheck provides many implicit Arbitrary generators for common types such as Int, String, List[Float], etc., in its org.scalacheck.Arbitrary companion object. So long as you use types for which ScalaCheck already provides implicit Arbitrary generators, you needn't worry about them. Same for Shrink objects, which are provided by ScalaCheck's org.scalacheck.Shrink companion object. Most often you can simply pass a property function to forAll, and the compiler will grab the implicit values provided by ScalaCheck.

    The forAll methods use the supplied Arbitrary generators to generate example arguments and pass them to the property function, and generate a GeneratorDrivenPropertyCheckFailedException if the function completes abruptly for any exception that would normally cause a test to fail in ScalaTest other than DiscardedEvaluationException. An DiscardedEvaluationException, which is thrown by the whenever method (defined in trait Whenever, which this trait extends) to indicate a condition required by the property function is not met by a row of passed data, will simply cause forAll to discard that row of data.

    Supplying argument names

    You can optionally specify string names for the arguments passed to a property function, which will be used in any error message when describing the argument values that caused the failure. To supply the names, place them in a comma separated list in parentheses after forAll before the property function (a curried form of forAll). Here's an example:

    forAll ("a", "b") { (a: String, b: String) =>
      a.length + b.length should equal ((a + b).length + 1) // Should fail
    }
    

    When this fails, you'll see an error message that includes this:

    Occurred when passed generated values (
      a = "",
      b = ""
    )
    

    When you don't supply argument names, the error message will say arg0, arg1, etc.. For example, this property check:

    forAll { (a: String, b: String) =>
      a.length + b.length should equal ((a + b).length + 1) // Should fail
    }
    

    Will fail with an error message that includes:

    Occurred when passed generated values (
      arg0 = "",
      arg1 = ""
    )
    

    Supplying generators

    ScalaCheck provides a nice library of compositors that makes it easy to create your own custom generators. If you want to supply custom generators to a property check, place them in parentheses after forAll, before the property check function (a curried form of forAll).

    For example, to create a generator of even integers between (and including) -2000 and 2000, you could write this:

    import org.scalacheck.Gen
    
    val evenInts = for (n <- Gen.choose(-1000, 1000)) yield 2 * n

    Given this generator, you could use it on a property check like this:

    forAll (evenInts) { (n) => n % 2 should equal (0) }
    

    Custom generators are necessary when you want to pass data types not supported by ScalaCheck's arbitrary generators, but are also useful when some of the values in the full range for the passed types are not valid. For such values you would use a whenever clause. In the Fraction class shown above, neither the passed numerator or denominator can be Integer.MIN_VALUE, and the passed denominator cannot be zero. This shows up in the whenever clause like this:

    whenever (d != 0 && d != Integer.MIN_VALUE
        && n != Integer.MIN_VALUE) { ...
    

    You could in addition define generators for the numerator and denominator that only produce valid values, like this:

    val validNumers =
      for (n <- Gen.choose(Integer.MIN_VALUE + 1, Integer.MAX_VALUE)) yield n
    val validDenoms =
      for (d <- validNumers if d != 0) yield d
    

    You could then use them in the property check like this:

    forAll (validNumers, validDenoms) { (n: Int, d: Int) =>
    
    whenever (d != 0 && d != Integer.MIN_VALUE && n != Integer.MIN_VALUE) {
    val f = new Fraction(n, d)
    if (n < 0 && d < 0 || n > 0 && d > 0) f.numer should be > 0 else if (n != 0) f.numer should be < 0 else f.numer should be === 0
    f.denom should be > 0 } }

    Note that even if you use generators that don't produce the invalid values, you still need the whenever clause. The reason is that once a property fails, ScalaCheck will try and shrink the values to the smallest values that still cause the property to fail. During this shrinking process ScalaCheck may pass invalid values. The whenever clause is still needed to guard against those values. (The whenever clause also clarifies to readers of the code exactly what the property is in a succinct way, without requiring that they find and understand the generator definitions.)

    Supplying both generators and argument names

    If you want to supply both generators and named arguments, you can do so by providing a list of (<generator>, <name>) pairs in parentheses after forAll, before the property function. Here's an example:

    forAll ((validNumers, "n"), (validDenoms, "d")) { (n: Int, d: Int) =>
    
    whenever (d != 0 && d != Integer.MIN_VALUE && n != Integer.MIN_VALUE) {
    val f = new Fraction(n, d)
    if (n < 0 && d < 0 || n > 0 && d > 0) f.numer should be > 0 else if (n != 0) f.numer should be < 0 else f.numer should be === 0
    f.denom should be > 0 } }

    Were this property check to fail, it would mention the names n and d in the error message, like this:

    Occurred when passed generated values (
      n = 17,
      d = 21
    )
    

    Property check configuration

    The property checks performed by the forAll methods of this trait can be flexibly configured via the services provided by supertrait Configuration. The five configuration parameters for property checks along with their default values and meanings are described in the following table:

    Configuration Parameter Default Value Meaning
    minSuccessful 100 the minimum number of successful property evaluations required for the property to pass
    maxDiscarded 500 the maximum number of discarded property evaluations allowed during a property check
    minSize 0 the minimum size parameter to provide to ScalaCheck, which it will use when generating objects for which size matters (such as strings or lists)
    maxSize 100 the maximum size parameter to provide to ScalaCheck, which it will use when generating objects for which size matters (such as strings or lists)
    workers 1 specifies the number of worker threads to use during property evaluation

    The forAll methods of trait GeneratorDrivenPropertyChecks each take a PropertyCheckConfiguration object as an implicit parameter. This object provides values for each of the five configuration parameters. Trait Configuration provides an implicit val named generatorDrivenConfig with each configuration parameter set to its default value. If you want to set one or more configuration parameters to a different value for all property checks in a suite you can override this val (or hide it, for example, if you are importing the members of the GeneratorDrivenPropertyChecks companion object rather than mixing in the trait.) For example, if you want all parameters at their defaults except for minSize and maxSize, you can override generatorDrivenConfig, like this:

    implicit override val generatorDrivenConfig =
      PropertyCheckConfiguration(minSize = 10, sizeRange = 10)
    

    Or, hide it by declaring a variable of the same name in whatever scope you want the changed values to be in effect:

    implicit val generatorDrivenConfig =
      PropertyCheckConfiguration(minSize = 10, sizeRange = 10)
    

    In addition to taking a PropertyCheckConfiguration object as an implicit parameter, the forAll methods of trait GeneratorDrivenPropertyChecks also take a variable length argument list of PropertyCheckConfigParam objects that you can use to override the values provided by the implicit PropertyCheckConfiguration for a single forAll invocation. For example, if you want to set minSuccessful to 500 for just one particular forAll invocation, you can do so like this:

    forAll (minSuccessful(500)) { (n: Int, d: Int) => ...
    

    This invocation of forAll will use 500 for minSuccessful and whatever values are specified by the implicitly passed PropertyCheckConfiguration object for the other configuration parameters. If you want to set multiple configuration parameters in this way, just list them separated by commas:

    forAll (minSuccessful(500), maxDiscardedFactor(0.6)) { (n: Int, d: Int) => ...
    

    If you are using an overloaded form of forAll that already takes an initial parameter list, just add the configuration parameters after the list of generators, names, or generator/name pairs, as in:

    // If providing argument names
    forAll ("n", "d", minSuccessful(500), maxDiscarded(300)) {
      (n: Int, d: Int) => ...
    
    // If providing generators forAll (validNumers, validDenoms, minSuccessful(500), maxDiscarded(300)) { (n: Int, d: Int) => ...
    // If providing (<generators>, <name>) pairs forAll ((validNumers, "n"), (validDenoms, "d"), minSuccessful(500), maxDiscarded(300)) { (n: Int, d: Int) => ...

    For more information, see the documentation for supertrait Configuration.

    Annotations
    @deprecated
    Deprecated

    GeneratorDrivenPropertyChecks has been moved from org.scalatest.prop to org.scalatestplus.scalacheck and renamed as ScalaCheckDrivenPropertyChecks. Please update your imports, as this deprecated type alias will be removed in a future version of ScalaTest.

  29. trait PropertyChecks extends TableDrivenPropertyChecks with GeneratorDrivenPropertyChecks

    Trait that facilitates property checks on data supplied by tables and generators.

    Trait that facilitates property checks on data supplied by tables and generators.

    This trait extends both TableDrivenPropertyChecks and GeneratorDrivenPropertyChecks. Thus by mixing in this trait you can perform property checks on data supplied either by tables or generators. For the details of table- and generator-driven property checks, see the documentation for each by following the links above.

    For a quick example of using both table and generator-driven property checks in the same suite of tests, however, imagine you want to test this Fraction class:

    class Fraction(n: Int, d: Int) {
    
    require(d != 0) require(d != Integer.MIN_VALUE) require(n != Integer.MIN_VALUE)
    val numer = if (d < 0) -1 * n else n val denom = d.abs
    override def toString = numer + " / " + denom }

    If you mix in PropertyChecks, you could use a generator-driven property check to test that the passed values for numerator and denominator are properly normalized, like this:

    forAll { (n: Int, d: Int) =>
    
    whenever (d != 0 && d != Integer.MIN_VALUE && n != Integer.MIN_VALUE) {
    val f = new Fraction(n, d)
    if (n < 0 && d < 0 || n > 0 && d > 0) f.numer should be > 0 else if (n != 0) f.numer should be < 0 else f.numer shouldEqual 0
    f.denom should be > 0 } }

    And you could use a table-driven property check to test that all combinations of invalid values passed to the Fraction constructor produce the expected IllegalArgumentException, like this:

    val invalidCombos =
      Table(
        ("n",               "d"),
        (Integer.MIN_VALUE, Integer.MIN_VALUE),
        (1,                 Integer.MIN_VALUE),
        (Integer.MIN_VALUE, 1),
        (Integer.MIN_VALUE, 0),
        (1,                 0)
      )
    
    forAll (invalidCombos) { (n: Int, d: Int) => an [IllegalArgumentException] should be thrownBy { new Fraction(n, d) } }

    Annotations
    @deprecated
    Deprecated

    PropertyChecks has been moved from org.scalatest.prop to org.scalatestplus.scalacheck and renamed as ScalaCheckPropertyChecks. Please update your imports, as this deprecated type alias will be removed in a future version of ScalaTest.

Value Members

  1. object Configuration extends Configuration

    Companion object that facilitates the importing of Configuration members as an alternative to mixing it in.

    Companion object that facilitates the importing of Configuration members as an alternative to mixing it in. One use case is to import Configuration members so you can use them in the Scala interpreter.

  2. object TableDrivenPropertyChecks extends TableDrivenPropertyChecks
  3. object TableFor1

    Companion object for class TableFor1 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor1 to return another TableFor1.

  4. object TableFor10

    Companion object for class TableFor10 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor10 to return another TableFor10.

  5. object TableFor11

    Companion object for class TableFor11 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor11 to return another TableFor11.

  6. object TableFor12

    Companion object for class TableFor12 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor12 to return another TableFor12.

  7. object TableFor13

    Companion object for class TableFor13 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor13 to return another TableFor13.

  8. object TableFor14

    Companion object for class TableFor14 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor14 to return another TableFor14.

  9. object TableFor15

    Companion object for class TableFor15 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor15 to return another TableFor15.

  10. object TableFor16

    Companion object for class TableFor16 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor16 to return another TableFor16.

  11. object TableFor17

    Companion object for class TableFor17 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor17 to return another TableFor17.

  12. object TableFor18

    Companion object for class TableFor18 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor18 to return another TableFor18.

  13. object TableFor19

    Companion object for class TableFor19 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor19 to return another TableFor19.

  14. object TableFor2

    Companion object for class TableFor2 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor2 to return another TableFor2.

  15. object TableFor20

    Companion object for class TableFor20 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor20 to return another TableFor20.

  16. object TableFor21

    Companion object for class TableFor21 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor21 to return another TableFor21.

  17. object TableFor22

    Companion object for class TableFor22 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor22 to return another TableFor22.

  18. object TableFor3

    Companion object for class TableFor3 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor3 to return another TableFor3.

  19. object TableFor4

    Companion object for class TableFor4 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor4 to return another TableFor4.

  20. object TableFor5

    Companion object for class TableFor5 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor5 to return another TableFor5.

  21. object TableFor6

    Companion object for class TableFor6 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor6 to return another TableFor6.

  22. object TableFor7

    Companion object for class TableFor7 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor7 to return another TableFor7.

  23. object TableFor8

    Companion object for class TableFor8 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor8 to return another TableFor8.

  24. object TableFor9

    Companion object for class TableFor9 that provides an implicit canBuildFrom method that enables higher order functions defined on TableFor9 to return another TableFor9.

  25. object Tables extends Tables

    Companion object that facilitates the importing of Tables members as an alternative to mixing it in.

    Companion object that facilitates the importing of Tables members as an alternative to mixing it in. One use case is to import Tables members so you can use them in the Scala interpreter:

    Welcome to Scala version 2.8.0.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
    Type in expressions to have them evaluated.
    Type :help for more information.
    
    scala> import org.scalatest.prop.Tables._
    import org.scalatest.prop.Tables._
    
    scala> val examples =
      |   Table(
      |     ("a", "b"),
      |     (  1,   2),
      |     (  3,   4)
      |   )
    examples: org.scalatest.prop.TableFor2[Int,Int] = TableFor2((1,2), (3,4))
    

Deprecated Value Members

  1. object Checkers extends Checkers

    Companion object that facilitates the importing of Checkers members as an alternative to mixing it in.

    Companion object that facilitates the importing of Checkers members as an alternative to mixing it in. One use case is to import Checkers members so you can use them in the Scala interpreter.

    Annotations
    @deprecated
    Deprecated

    Checkers has been moved from org.scalatest.prop to org.scalatestplus.scalacheck. Please update your imports, as this deprecated type alias will be removed in a future version of ScalaTest.

  2. object GeneratorDrivenPropertyChecks extends GeneratorDrivenPropertyChecks
    Annotations
    @deprecated
    Deprecated

    GeneratorDrivenPropertyChecks has been moved from org.scalatest.prop to org.scalatestplus.scalacheck and renamed as ScalaCheckDrivenPropertyChecks. Please update your imports, as this deprecated type alias will be removed in a future version of ScalaTest.

  3. object PropertyChecks extends PropertyChecks

    Companion object that facilitates the importing of PropertyChecks members as an alternative to mixing it in.

    Companion object that facilitates the importing of PropertyChecks members as an alternative to mixing it in. One use case is to import PropertyChecks members so you can use them in the Scala interpreter.

    Annotations
    @deprecated
    Deprecated

    PropertyChecks has been moved from org.scalatest.prop to org.scalatestplus.scalacheck and renamed as ScalaCheckPropertyChecks. Please update your imports, as this deprecated type alias will be removed in a future version of ScalaTest.

Inherited from AnyRef

Inherited from Any

Ungrouped