specs


a BDD library for Scala

Welcome to specs!

specs is now deprecated, please use specs2 instead!

|06/03/2011 | specs2 1.0 | specs2 is released! - Maintenance will go on with specs but new features are only provided with specs2: acceptance testing, concurrent execution,... So please, start any new project with specs2!| |:----------|:---------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |09/4/2011 | http://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Nuvola_apps_mozilla.png/20px-Nuvola_apps_mozilla.png specs 1.6.9 | Maintenance release for Scala 2.9.1(enhancements and fixes) | |11/10/2010 | specs 1.6.6 | Scala 2.8.1 release! (enhancements and fixes) | |02/04/2010 | specs 1.6.2 | NEW: Added a test-interface runner to execute specifications with sbt. Added Eventually matchers to retry matchers evaluation (Thanks to Robey Pointer). Other improvements and fixes| |11/05/2009 | specs 1.6.1 | 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. |

specs is a Behaviour-Driven-Design framework which provides:

  • a simple and typed language to create specifications (your first specification in 5 minutes) 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.*") } }
  • lots of matchers to specify code properties: ``` "myString" must be matching("Str.*")

    // or to specify xml pieces using XPath-like operators: must \("c").("d") ```

  • an integration with JUnit to so that you can run and report your tests using your existing infrastructure (you can also run the tests in the console or generate an xml file with the results)
  • an easy way to specify combinatorial properties through an integration with Scalacheck: // generates 500 different mail addresses mailAddresses must pass { address => address must beMatching(companyPattern) }
  • an integration with Mockito (JMock and EasyMock are also available): ``` 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]) } } } ```

  • lots of possibilities to structure and compose specifications class compositeSpec extends Specification { "A composite spec" isSpecifiedBy (okSpec, koSpec) }
  • the possibility to reuse examples across specs (see the stackSpec example): "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: ``` 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 } } } } ``` * a FIT-like library for business specifications: Forms

The first time

You 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!

<wiki:gadget url="http://www.ohloh.net/p/10595/widgets/project_users_logo.xml" height="43" border="0" />

Project Information

Labels:
scala bdd junit scalacheck scalatest jmock simple-build-tool mockito