import org.specs2.mutable._
class HelloWorldSpec extends Specification {
"The 'Hello world' string" should {
"contain 11 characters" in {
"Hello world" must have size(11)
}
"start with 'Hello'" in {
"Hello world" must startWith("Hello")
}
"end with 'world'" in {
"Hello world" must endWith("world")
}
}
}
import org.specs2._
class HelloWorldSpec extends Specification { def is =
"This is a specification to check the 'Hello world' string" ^
p^
"The 'Hello world' string should" ^
"contain 11 characters" ! e1^
"start with 'Hello'" ! e2^
"end with 'world'" ! e3^
end
def e1 = "Hello world" must have size(11)
def e2 = "Hello world" must startWith("Hello")
def e3 = "Hello world" must endWith("world")
}
Concurrent execution of examples by default
ScalaCheck properties
Mocks with Mockito
Data tables
AutoExamples, where the source code is extracted to describe the example
A rich library of matchers
Easy to create and compose
Usable with must and should
Returning "functional" results or throwing exceptions
Reusable outside of specs2 (in JUnit tests for example)
Forms for writing Fitnesse-like specifications (with Markdown markup)
Html reporting to create documentation for acceptance tests, to create a User Guide,...
Integration with sbt and JUnit tools (maven, IDEs,...)
libraryDependencies ++= Seq(
"org.specs2" %% "specs2" % "${SPECS2_VERSION}" % "test"
// with Scala 2.9.2 (specs2 1.12.3 is the latest version for scala 2.9.2)
// "org.specs2" %% "specs2" % "1.12.3" % "test",
)
// Read here for optional dependencies:
// http://etorreborre.github.com/specs2/guide/org.specs2.guide.Runners.html#Dependencies
resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"releases" at "http://oss.sonatype.org/content/repositories/releases")
<dependency>
<groupId>org.specs2</groupId>
<artifactId>specs2_2.10</artifactId>
<version>${SPECS2_VERSION}</version>
<scope>test</scope>
</dependency>
<!--
with Scala 2.9.2, change the dependency to:
<artifactId>specs2_2.9.2</artifactId>
<version>1.12.3</version>
-->
<!--
Read here for optional dependencies:
http://etorreborre.github.com/specs2/guide/org.specs2.guide.Runners.html#Dependencies
-->
<repository>
<id>oss.sonatype.org</id>
<name>releases</name>
<url>http://oss.sonatype.org/content/repositories/releases</url>
</repository>
<repository>
<id>oss.sonatype.org</id>
<name>snapshots</name>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>central</id>
<name>Maven repository</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
| Version | Files |
|---|---|
| Snapshot |
binaries (specs2 jar,
scalaz core jar,
scalaz concurrent jar) project (zip, tar) |
| Released |
binaries (specs2 jar,
scalaz core jar,
scalaz concurrent jar) project (zip, tar) |