Chapter 4. Specs2
Specs2 is a testing framework with a different focus and perspective that’s different from ScalaTest’s. Much like ScalaTest’s, Specs2 works with SBT, but it has some unique differences that a developer may choose based on the functionality needed. Specs2 has a different set of matchers, a different way of structuring tests, as well as DataTable specifications, AutoExamples, and Fitnesse style specifications used for collaboration purposes with the stakeholders of your project. Specs2 tests are also unique in that they are concurrently executed in each thread.
Setting Up Specs2 in SBT
Since the book is focused on testing frameworks used with SBT, the following setup in build.sbt will bring in some dependencies and resolvers that are required for Specs2 to run.
name := "Testing Scala" version := "1.0" scalaVersion := "2.9.2" resolvers ++= Seq( "snapshots" at "http://scala-tools.org/repo-snapshots", "releases" at "http://scala-tools.org/repo-releases") resolvers ++= Seq( "sonatype-snapshots" at "http://oss.sonatype.org/content /repositories/snapshots", "sonatype-releases" at "http://oss.sonatype.org/content /repositories/releases") libraryDependencies ++= Seq( "org.scalatest" % "scalatest_2.9.2" % "1.8" % "test" withSources() withJavadoc(), "joda-time" % "joda-time" % "1.6.2" withSources() withJavadoc(), "junit" % "junit" % "4.10" withSources() withJavadoc(), "org.testng" % "testng" % "6.1.1" % "test" withSources() withJavadoc(), "org.specs2" %% "specs2" % "1.12.3" withSources() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access