Welcome to specs!
| 11/05/2009 | | NEW: Added "around" actions that can be executed around the expectations of an example. Added SpecContexts. Added a plan option to display the plan of a specification without executing the examples. Other improvements and fixes |
| 09/08/2009 | specs 1.6.0 | NEW: new execution model with automated clean-up of local variables and first-class subexamples. Added an EasyMock trait. Other improvements and fixes |
| 05/07/2009 | specs 1.5.0 | NEW: Easier syntax with be/have + matcher. Alpha version of literate specifications and Forms. Other improvements and fixes: run options, configuration, pending examples. |
| 04/06/2009 | specs 1.4.4 | NEW: Added a Mockito trait to use the Mockito library for mock objects. Added new command-line options. Documented the System contexts and added a way to use them with implicit vals. Changed the Maven group id to org.scala-tools.testing. See fixes and other improvements here |
| 02/12/2009 | specs 1.4.3 | NEW: Added a "-xonly" or "--failedonly" option to only display failures and errors in the console. Fixed issues and added 2 matchers. |
| 01/14/2009 | specs 1.4.2 | NEW: Upgraded to Scala-2.7.3. Added a new TeamCity runner (thanks to Stepan Koltsov). |
specs is a Behaviour-Driven-Design framework which provides:
- a simple and typed language to create specifications (your first specification in 5 minutes)
object 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)
}object 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
mock.send(any[Mail]) was called
}
}
}object 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]
}
}- data tables to group several data examples at once:
object addOperationSpec extends Specification with org.specs.util.DataTables {
"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 time
You can download the current library distribution (or get it with Maven) and execute:
java -cp specs-1.6.1.jar;specs-1.6.1-tests.jar;scalacheck-1.6.jar;scala-library-2.7.7.jar;junit-4.5.jar;cglib-2.1_3.jar;asm-1.5.3.jar;objenesis-1.1.jar;hamcrest-all-1.1.jar;jmock-2.4.0.jar;mockito-all-1.8.0.jar;easymock-2.5.1.jar;easymockclassextension-2.4.jar;wikitext.core-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 19 seconds, 47 ms 1038 examples, 7771 expectations, 0 failure, 0 error
tested with Scala 2.7.7
Happy specs!