Skip to main content

Integration with Minitest

Minitest

Scala Hedgehog provides an integration module for minitest. This allows you to define property-based and example-based Hedgehog tests within a minitest test suite. If you use this integration, you won't need to Scala Hedgehog sbt testing extension, because you're using the one provided by minitest:

val hedgehogVersion = "0.10.1"
libraryDependencies += "qa.hedgehog" %% "hedgehog-minitest" % hedgehogVersion % Test
NOTE

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")
NOTE

For sbt version 1.9.1 or higher, this step is not necessary, as Hedgehog is supported by default.

Here's an example of using hedgehog-minitest:

import minitest.SimpleTestSuite
import hedgehog.minitest.HedgehogSupport
import hedgehog._

object ReverseTest extends SimpleTestSuite with HedgehogSupport {
property("reverse alphabetic strings") {
for {
xs <- Gen.alpha.list(Range.linear(0, 100)).forAll
} yield xs.reverse.reverse ==== xs
}
example("reverse hello") {
"hello".reverse ==== "olleh"
}
}