Specs2 data tables

Data tables in Specs2 are similar to the table in table-driven property checks. The table consists of a sample input value and an expected result. A function test case follows the table that is run for each row of the table with inputs acting as input to the function, and the result of the function is verified with the expected output in the table:

package com.packt import org.specs2.matcher.DataTables import org.specs2.Specification class EmployeeAgeSpecification extends Specification with DataTables {def is = "Trying out a table of values for testing purposes to determine the age of an employee".name ^ """The first column is the employee first name, the second is a employee last name, and third is Year of Birth and the forth ...

Get Scala Test-Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.