Installation

The recommended way to install specs2 is via sbt.

SBT

First you need to install sbt itself then you need to add the specs2 dependency:

libraryDependencies += "org.specs2" %% "specs2-core" % "5.2.0" % "test"

// if you want to use ScalaJS you need to use %%%
libraryDependencies += "org.specs2" %%% "specs2-core" % "5.2.0" % "test"

// ScalaJS also requires the following setting which supports
// the regular expressions used in many specs2 matchers using strings
scalaJSLinkerConfig ~= { _.withESFeatures(_.withESVersion(ESVersion.ES2018)) }

See here to learn more about sbt dependencies.

Other dependencies

Depending on the specs2 features you want to use you will need to add more dependencies to your build:

Name Functionality
specs2-matcher-extra for the optional specs2 matchers
specs2-html to export specifications as html
specs2-form to create html form-like specifications (experimental)
specs2-junit to run specifications as JUnit tests
scalamock to use mocks in specifications (see the ScalaMock project)
specs2-scalacheck to use ScalaCheck properties in specifications (see the ScalaCheck project)
specs2-cats for the cats matchers (see specs2-cats)
specs2-scalaz for the scalaz matchers (see specs2-scalaz)

Note: the specs2-core jar depends on 3 other specs2 jars:

Name Functionality
specs2-fp utility classes for functional programming
specs2-common utility classes for text, collections, xml,…
specs2-matcher common specs2 matchers. They can be used as a stand-alone library with JUnit