|
|
Welcome to specs!
| 7/21/2008 | | NEW: Added tags to include and exclude examples from specs at execution time. (Other fixes and improvements). |
| 6/20/2008 | specs 1.3.0 | NEW: repeated examples, anonymous examples, one liner methods for jMock, capturing parameters for jMock, detailed differences using the Edit distance. Fixed issue 29 and time reporting in the console |
| 5/27/2008 | specs 1.2.9 | NEW: Added contexts for better specification structuration (see the reworked stack specification sample) |
| 5/24/2008 | specs 1.2.8 | NEW: added some FileMatchers. Defined a reusable SpecsMatchers trait to be able to reuse specs matchers outside of a specification. Added a -ns or --nostacktrace option to the ConsoleRunner to remove stacktraces from the console output. (Other fixes and improvements) |
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 mustBe 11
}
"'hello world' matches 'h.* w.*'" in {
"hello world" must beMatching("h.* w.*")
}
} "myString" must beMatching("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 JMocker {
"A Send service" should {
"publish data" in {
// define a mock
val mock = mock(classOf[Mailer])
// define expectations
expect {
one(mock).send(any(classOf[Mail]))
}
// use the mock, the expectations are automatically checked at the end of the example
val sendService = new SendService(mock)
sendService.publishData
}
}
}compositeSpec.suts must beLike { case x::y::Nil => (x, y) == (okSpec.suts.head, okSpec.suts.head) }object compositeSpec extends Specification {
"A composite spec" isSpecifiedBy (okSpec, koSpec)
}"A stack below full capacity" ->-(belowCapacity) should {
behave like "A non-empty stack below full capacity"
"add to the top when sent #push" in {
stack push 3
stack.top mustBe 3
}
}- 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.3.1.jar;specs-1.3.1-tests.jar;scalacheck-1.3.jar;scala-library-2.7.1.jar;junit-4.4.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 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, 16 ms 484 examples, 2350 assertions, 0 failure, 0 error
tested with Scala 2.7.1-final
Happy specs!
