I can't seem to figure out how to integrate the three. I've found how to test using specs2
and scalacheck
like the following:
class ExampleSpec extends Specification with ScalaCheck { def is = s2"""
Example
scalacheck $e1
"""
def e1 = prop((i: Int) => i == i)
}
using the so-called Acceptance specification
style.
However, with Play
, Unit specification
style is mandatory to make use of goodies like WithApplication
and whatnot.
I naively thought this would work:
class PlayExampleSpec extends PlaySpecification with ScalaCheck {
"Play" in new WithApplication() {
"scalacheck" in prop((s: String) => s == s)
}
}
The test doesn't get executed at all. I've looked through half the internet to no avail. Please help.
If you are using WithApplication
you need to be able to throw exceptions when a property fails (because prop
is pure and will get lost in the body of WithApplication
). AsResult
does this for you:
import org.specs2.execute.AsResult
class TestMutableSpec extends mutable.Specification with ScalaCheck {
"Example" in new WithApplication {
AsResult {
prop((s: String) => s != s)
}
}
}
The example above should fail.