|
Project Information
Members
Featured
Downloads
Wiki pages
Links
|
Welcome to specs!specs is now deprecated, please use specs2 instead!
specs is a Behaviour-Driven-Design framework which provides:
class helloWorld extends Specification {
"'hello world' has 11 characters" in {
"hello world".size must be equalTo(11)
}
"'hello world' matches 'h.* w.*'" in {
"hello world" must be matching("h.* w.*")
}
} "myString" must be matching("Str.*")
// or to specify xml pieces using XPath-like operators:
<a><b><c><d></d></c></b></a> must \\("c").\("d")// generates 500 different mail addresses
mailAddresses must pass { address =>
address must beMatching(companyPattern)
}class SendSpec extends Specification with Mockito {
"A Send service" should {
"publish data" in {
val mock = mock[Mailer]
// use the mock
val sendService = new SendService(mock)
sendService.publishData
// check that the mock was called
there was one(mock).send(any[Mail])
}
}
}class compositeSpec extends Specification {
"A composite spec" isSpecifiedBy (okSpec, koSpec)
}"A full stack"->-(fullStack) should {
behave like "A non-empty stack below full capacity"
"throw an exception when sent #push" in {
stack.push(11) must throwAn[Error]
}
}
import org.specs.util.DataTables
class addOperationSpec extends Specification withDataTables {
"provide an add operation" in {
"a" | "b" | "result" |>
1 ! 2 ! 3 |
5 ! 2 ! 7 |
3 ! 0 ! 3 | { (a, b, c) => { a + b must_== c } }
}
}The first timeYou can download the current library distribution (or get it with Maven) and execute: java -cp specs-1.6.7.jar;specs-1.6.7-tests.jar;scalacheck-1.8.jar;scala-library-2.8.1.jar; junit-4.7.jar; scalatest-1.2.jar; cglib-2.1_3.jar;asm-1.5.3.jar;objenesis-1.1.jar;hamcrest-all-1.1.jar;jmock-2.5.1.jar;jmock-legacy-2.5.1.jar;mockito-all-1.8.5.jar;easymock-2.5.1.jar;easymockclassextension-2.4.jar;wikitext-0.9.4.I20090220-1600-e3x.jar;wikitext.textile-0.9.4.I20090220-1600-e3x.jar; -Xmx512m org.specs.allRunner Then you should see the whole specification for the specs project, ending with: Total for specification "The specs and unit tests for the specs project": Finished in 36 seconds, 706 ms 1262 examples, 7167 expectations, 0 failure, 0 error tested with Scala 2.8.1.final Happy specs!
|