Getting Started
Getting Started
SBT Binary Dependency
In your build.sbt
, add the following libraryDependencies
.
val hedgehogVersion = "0.10.1"
libraryDependencies ++= Seq(
"qa.hedgehog" %% "hedgehog-core" % hedgehogVersion,
"qa.hedgehog" %% "hedgehog-runner" % hedgehogVersion,
"qa.hedgehog" %% "hedgehog-sbt" % hedgehogVersion
).map(_ % Test)
Supported Scala Versions:
2.11
,2.12
,2.13
and3.1+
SBT Source Dependency
This project can be added as an SBT subproject.
// This can also be a branch name, like 'master'`, if you want to live on the edge
val hedgehogVersion = "${COMMIT}"
val hedgehogUri = uri("https://github.com/hedgehogqa/scala-hedgehog.git#" + hedgehogVersion)
lazy val root =
(project in file("."))
.dependsOn(ProjectRef(hedgehogUri, "core"))
.dependsOn(ProjectRef(hedgehogUri, "runner"))
.dependsOn(ProjectRef(hedgehogUri, "sbt-test"))
NOTE: Depending on your scala version(s) SBT might not resolve.
SBT Testing
Scala Hedgehog comes with a very primitive runner interface, and supports the SBT testing extension.
If you're using sbt version 1.9.0
or lower, you need to add the following line to your build.sbt
file:
testFrameworks += TestFramework("hedgehog.sbt.Framework")
For sbt version 1.9.1
or higher, this step is not necessary, as Hedgehog is supported by default.
IntelliJ
The IntelliJ scala plugin only has
hard-coded support for the most popular test frameworks.
While Hedgehog is obviously not included in that list, an may never be, by extending the runner
Properties
tests can be run as an application (as Properties
includes a handy main
function).
NOTE: This requires the test to be an object
and not a class
.
Example
See the examples module for working versions.
import hedgehog._
import hedgehog.runner._
object PropertyTest extends Properties {
def tests: List[Test] =
List(
property("reverse", testReverse)
)
def testReverse: Property =
for {
xs <- Gen.alpha.list(Range.linear(0, 100)).forAll
} yield xs.reverse.reverse ==== xs
}