|
QuickStart
Your first specification starts here!
(for more information, take a look at the User Guide)
import org.specs._ object helloWorld extends Specification import org.specs._
object helloWorld extends Specification {
"'hello world' has 11 characters" in {}
"'hello world' matches 'h.* w.*'" in {}
}import org.specs._
object helloWorld extends Specification {
"'hello world' has 11 characters" in {
"hello world".size must_== 11
}
"'hello world' matches 'h.* w.*'" in {
"hello world" must be matching("h.* w.*")
}
}Specification "helloWorld" specifies + 'hello world' has 11 characters + 'hello world' matches 'h.* w.*' Total for specification "helloWorld": Finished in 0 second, 63 ms 2 examples, 2 assertions, 0 failure, 0 error import org.specs._
object helloWorld extends Specification {
"hello world" should {
"have 11 characters" in {
"hello world".size must_== 11
}
"match 'h.* w.*'" in {
"hello world" must be matching("h.* w.*")
}
}
"Good bye cruel world" should {...}
}import org.specs.runner._
class helloWorldTest extends JUnit4(helloWorld)
// OR declare your specification as a class and mix-in the JUnit trait
// in that case, the specification can still be run on the command line with
// `scala -cp specs-<version>.jar run helloWorld`
class helloWorld extends Specification with JUnit { ... }
Note: helloWorldTest is declared as a class and not an object to be instantiated properly by JUnit runners.
|
Sign in to add a comment
5. now, you can add more structure to your specification
No joy getting helloWorld Specification to run: specs1.6.1, scala 2.7.7.final, java1.6.0_15 on OS X
scalac -cp ~/work/specs1.6.1/specs-1.6.1.jar helloWorld.scala scala -cp .:~/work/specs1.6.1/specs-1.6.1.jar helloWorld Exception in thread "main" java.lang.NoClassDefFoundError??: org/specs/matcher/Matcher
Caused by: java.lang.ClassNotFoundException??: org.specs.matcher.Matcher