HedgehogSuite

abstract class HedgehogSuite extends FunSuite with HedgehogAssertions
class FunSuite
trait ValueTransforms
trait SuiteTransforms
trait TestTransforms
trait TestOptionsConversions
trait FunFixtures
trait Assertions
trait CompileErrorMacro
class Suite
trait PlatformSuite
class Object
trait Matchable
class Any

Type members

Inherited classlikes

abstract class Fixture[T](val fixtureName: String)
Value parameters:
name

The name of this fixture, used for displaying an error message if beforeAll() or afterAll() fail.

Inherited from:
Suite
class FunFixture[T]
Inherited from:
FunFixtures
object FunFixture
Inherited from:
FunFixtures
final class SuiteTransform(val name: String, fn: List[Test] => List[Test]) extends List[Test] => List[Test]
Inherited from:
SuiteTransforms
final class TestTransform(val name: String, fn: Test => Test) extends Test => Test
Inherited from:
TestTransforms
final class ValueTransform(val name: String, fn: PartialFunction[Any, Future[Any]]) extends Any => Option[Future[Any]]
Inherited from:
ValueTransforms

Inherited types

final type AfterEach = GenericAfterEach[TestValue]
Inherited from:
Suite
final type BeforeEach = GenericBeforeEach[TestValue]
Inherited from:
Suite
type Failure = Failure
See also:

hedgehog.core.Result.Failure

Inherited from:
HedgehogAssertions
type Success = Success.type
See also:

hedgehog.core.Result.Success

Inherited from:
HedgehogAssertions
final type Test = GenericTest[TestValue]
Inherited from:
Suite
final type TestValue = Future[Any]
Inherited from:
FunSuite

Value members

Concrete methods

def property(name: String, withConfig: PropertyConfig => PropertyConfig)(prop: => Property)(implicit loc: Location): Unit

Runs a hedgehog property-based test.

Runs a hedgehog property-based test.

Value parameters:
loc

The location in the test suite source file

prop

The property under test

withConfig

A function with which to change the test PropertyConfig

See also:

hedgehog.runner.property

Inherited methods

def Failure(log: List[Log]): Failure

Alias for Result.Failure

Alias for Result.Failure

See also:

See hedgehog.core.Result.Failure

Inherited from:
HedgehogAssertions
def afterAll(): Unit

Runs once after all test cases and after all suite-local fixtures have been tear down.

Runs once after all test cases and after all suite-local fixtures have been tear down.

Inherited from:
Suite
def afterEach(context: AfterEach): Unit

Runs after each individual test case.

Runs after each individual test case.

Inherited from:
Suite
def all(l: List[Result]): Result

Alias for Result.all

Alias for Result.all

See also:

hedgehog.core.Result.all

Inherited from:
HedgehogAssertions
def any(l: List[Result]): Result

Alias for Result.any

Alias for Result.any

See also:

hedgehog.core.Result.any

Inherited from:
HedgehogAssertions
def assert(cond: => Boolean): Result

Fails the test with a failure Result when cond is false.

Fails the test with a failure Result when cond is false.

Returns:

Success iff cond is true. Failure otherwise.

Inherited from:
HedgehogAssertions
def assert(cond: => Boolean, clue: => Any)(implicit loc: Location): Unit
Inherited from:
Assertions
def assertEquals[A, B](obtained: A, expected: B)(implicit ev: B <:< A): Result

Fails the test if obtained and expected are non-equal using ==.

Fails the test if obtained and expected are non-equal using ==.

Value parameters:
expected

The expected value

obtained

The actual value

Returns:

Success iff obtained == expected. Failure otherwise.

Inherited from:
HedgehogAssertions
def assertEquals[A, B](obtained: A, expected: B, clue: => Any)(implicit loc: Location, ev: B <:< A): Unit

Asserts that two elements are equal using == equality.

Asserts that two elements are equal using == equality.

The "expected" value (second argument) must have the same type or be a subtype of the "obtained" value (first argument). For example:

 assertEquals(Option(1), Some(1)) // OK
 assertEquals(Some(1), Option(1)) // Error: Option[Int] is not a subtype of Some[Int]

Use assertEquals[Any, Any](a, b) as an escape hatch to compare two values of different types. For example:

 val a: Either[List[String], Int] = Right(42)
 val b: Either[String, Int]       = Right(42)
 assertEquals[Any, Any](a, b) // OK
 assertEquals(a, b) // Error: Either[String, Int] is not a subtype of Either[List[String], Int]
Inherited from:
Assertions
def assertEqualsDouble(obtained: Double, expected: Double, delta: Double, clue: => Any)(implicit loc: Location): Unit

Asserts that two doubles are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes.

Asserts that two doubles are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes.

Inherited from:
Assertions
def assertEqualsFloat(obtained: Float, expected: Float, delta: Float, clue: => Any)(implicit loc: Location): Unit

Asserts that two floats are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes.

Asserts that two floats are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes.

Inherited from:
Assertions
def assertNoDiff(obtained: String, expected: String): Result

Asserts two strings are equal.

Asserts two strings are equal.

Value parameters:
expected

The expected value

obtained

The actual string

Returns:

Success iff actual is obtained. Failure otherwise.

Inherited from:
HedgehogAssertions
def assertNoDiff(obtained: String, expected: String, clue: => Any)(implicit loc: Location): Unit
Inherited from:
Assertions
def assertNotEquals[A, B](obtained: A, expected: B)(implicit ev: A =:= B): Result

Asserts two values are nonequal.

Asserts two values are nonequal.

Value parameters:
ev

Ensures that obtained and expected are of the same type.

expected

The expected value

obtained

The actual value

Returns:

Success iff obtained != actua.

Inherited from:
HedgehogAssertions
def assertNotEquals[A, B](obtained: A, expected: B, clue: => Any)(implicit loc: Location, ev: A =:= B): Unit
Inherited from:
Assertions
def assume(cond: Boolean, clue: => Any)(implicit loc: Location): Unit
Inherited from:
Assertions
def beforeAll(): Unit

Runs once before all test cases and before all suite-local fixtures are setup. An error in this method aborts the test suite.

Runs once before all test cases and before all suite-local fixtures are setup. An error in this method aborts the test suite.

Inherited from:
Suite
def beforeEach(context: BeforeEach): Unit

Runs before each individual test case. An error in this method aborts the test case.

Runs before each individual test case. An error in this method aborts the test case.

Inherited from:
Suite
def clue[T](c: Clue[T]): T
Inherited from:
Assertions
def clues(clue: Clue[_]*): Clues
Inherited from:
Assertions
inline def compileErrors(inline code: String): String
Inherited from:
CompileErrorMacro
def diff[A, B](a: A, b: B)(f: (A, B) => Boolean): Result

Alias for Result.diff

Alias for Result.diff

See also:

hedgehog.core.Result.diff

Inherited from:
HedgehogAssertions
def diffDouble(obtained: Double, expected: Double, delta: Double): Result

Asserts two doubles are equal +- some erorr value.

Asserts two doubles are equal +- some erorr value.

Value parameters:
delta

The error allowed for double == comparison. Default is 0.00.

expected

The expected value.

obtained

The actual value.

Returns:

Success iff obtained approximately equals expected +- delta. Failure otherwis

Inherited from:
HedgehogAssertions
def diffFloat(obtained: Float, expected: Float, delta: Float): Result

Float specialized version of HedgehogAssertions.assertEquals.

Float specialized version of HedgehogAssertions.assertEquals.

Asserts two floats are equal within +- some error value.

Value parameters:
delta

The error allowed for float == comparison. Default is 0.0f

expected

The expected value

obtained

The actual value

Returns:

Success iff obtained approximately equals expected +- delta. Failure otherwise.

Inherited from:
HedgehogAssertions
def diffNamed[A, B](logName: String, a: A, b: B)(f: (A, B) => Boolean): Result

Alias for Result.diffNamed

Alias for Result.diffNamed

See also:

hedgehog.core.Result.diffNamed

Inherited from:
HedgehogAssertions
def error(e: Exception): Result

Alias for Result.error

Alias for Result.error

See also:

hedgehog.core.Result.error

Inherited from:
HedgehogAssertions
def fail(message: String): Result

Fails a test with the given message

Fails a test with the given message

Returns:

Failure, always.

Inherited from:
HedgehogAssertions
def fail(message: String, cause: Throwable): Result

Fails a test.

Fails a test.

Analagous to munit.Assertions.fail.

Value parameters:
cause

An optional underlying exception to use as the cause of the failure.

message

The message to include in the failure.

Returns:

Failure, always.

Inherited from:
HedgehogAssertions
def fail(message: String, clues: Clues)(implicit loc: Location): Nothing
Inherited from:
Assertions
def fail(message: String, cause: Throwable)(implicit loc: Location): Nothing
Inherited from:
Assertions
def failComparison(message: String, obtained: Any, expected: Any, clues: Clues)(implicit loc: Location): Nothing
Inherited from:
Assertions
def failSuite(message: String, clues: Clues)(implicit loc: Location): Nothing
Inherited from:
Assertions
def failure: Result

Alias for Result.failure

Alias for Result.failure

See also:

hedgehog.core.Result.failure

Inherited from:
HedgehogAssertions
def intercept[T <: Throwable](body: => Any)(implicit T: ClassTag[T], loc: Location): T
Inherited from:
Assertions
def interceptMessage[T <: Throwable](expectedExceptionMessage: String)(body: => Any)(implicit T: ClassTag[T], loc: Location): T
Inherited from:
Assertions
def isCI: Boolean
Inherited from:
SuiteTransforms
def munitAnsiColors: Boolean
Inherited from:
Assertions
def munitCaptureClues[T](thunk: => T): (T, Clues)
Inherited from:
Assertions
def munitExecutionContext: ExecutionContext
Inherited from:
Suite
Inherited from:
TestTransforms
def munitFixtures: Seq[Fixture[_]]

Functinonal fixtures that can be reused for individual test cases or entire suites.

Functinonal fixtures that can be reused for individual test cases or entire suites.

Inherited from:
Suite
def munitFlakyOK: Boolean
Inherited from:
TestTransforms
Inherited from:
TestTransforms
Inherited from:
ValueTransforms
def munitIgnore: Boolean
Inherited from:
SuiteTransforms
Inherited from:
SuiteTransforms
Inherited from:
SuiteTransforms
def munitPrint(clue: => Any): String
Inherited from:
Assertions
final def munitSuiteTransform(tests: List[Test]): List[Test]
Inherited from:
SuiteTransforms
Inherited from:
SuiteTransforms
final def munitTestTransform(test: Test): Test
Inherited from:
TestTransforms
Inherited from:
TestTransforms
def munitTests(): Seq[Test]
Inherited from:
FunSuite
def munitTimeout: Duration
Inherited from:
FunSuite
final def munitValueTransform(testValue: => Any): Future[Any]
Inherited from:
ValueTransforms
Inherited from:
ValueTransforms
def success: Result

Alias for Result.success

Alias for Result.success

See also:

hedgehog.core.Result.success

Inherited from:
HedgehogAssertions
def test(options: TestOptions)(body: => Any)(implicit loc: Location): Unit
Inherited from:
FunSuite
def test(name: String)(body: => Any)(implicit loc: Location): Unit
Inherited from:
FunSuite
def withMunitAssertions(body: => Assertions => Any): Any

Turns off hedgehog munit-like assertions, so users can use both property- and non-property- based-tests in their test suites. By using the passed assertions parameter, all the standard munit assertions that do not return unit are available, despite name ambiguities.

Turns off hedgehog munit-like assertions, so users can use both property- and non-property- based-tests in their test suites. By using the passed assertions parameter, all the standard munit assertions that do not return unit are available, despite name ambiguities.

==Usage==

 test("1 + 1 is 2"){
   withMunitAssertions{ assertions =>
     assertEquals(1 + 1, 2)
   }
 }
Value parameters:
body

a test body, taking an assertions parameter

Inherited from:
HedgehogAssertions

Deprecated and Inherited methods

@deprecated("Clues are unnecessary with hedgehog. Use HedgehogAssertions.diff, which will automatically output clues", "")
def assert(cond: => Boolean, clue: => Any): Result

Fails the test with a failure Result when cond is false.

Fails the test with a failure Result when cond is false.

Analagous to munit.Assertions.assert.

Only the condition is used. Clues are ignored.

Value parameters:
clue

ignored -- usage triggers the deprecation warning

Returns:

Success iff cond is true. Failure otherwise.

Deprecated
Inherited from:
HedgehogAssertions
@deprecated("Clues are unnecessary with hedgehog. Use HedgehogAssertions.assertEquals, which will automatically output clues", "")
def assertEquals[A, B](obtained: A, expected: B, clue: => Any)(implicit ev: B <:< A): Result

Fails the test if obtained and expected are non-equal using ==.

Fails the test if obtained and expected are non-equal using ==.

Analagous to munit.Assertions.assert.

Only the obtained and expected values are used.

Value parameters:
clue

Ignored -- Triggers deprecation warning

ev

Evidence that A and B are of the same type for the comparison to be valid.

obtained

The actual value

Returns:

Success iff obtained == expected. Failure otherwise.

Deprecated
Inherited from:
HedgehogAssertions
@deprecated("Clues are unnecessary with hedgehog. Use HedgehogAssertions.diffDouble, which will automatically output clues", "")
def assertEqualsDouble(obtained: Double, expected: Double, delta: Double, clue: => Any): Result

Double specialized version of HedgehogAssertions.assertEquals.

Double specialized version of HedgehogAssertions.assertEquals.

Asserts two double values are equal +- some error value.

Analagous to munit.Assertions.assertEqualsDouble.

Only the obtained, expected and delta parameters are used.

Value parameters:
clue

Ignored -- usage triggers a deprecation warning

delta

The error allowed for double == comparison.

expected

The expected value.

obtained

The actual value.

Returns:

Success iff obtained approximately equals expected +- delta. Failure otherwise.

Deprecated
Inherited from:
HedgehogAssertions
@deprecated("Clues are unnecessary with hedgehog. Use HedgehogAssertions.diffFloat, which will automatically output clues", "")
def assertEqualsFloat(obtained: Float, expected: Float, delta: Float, clue: => Any): Result

Float specialized version of assertEquals.

Float specialized version of assertEquals.

Asserts two floats are equal within +- some error value.

Analagous to munit.Assertions.assertEqualsFloat.

Value parameters:
clue

Ignored -- usage triggers deprecation warning

delta

The error allowed for float == comparison.

expected

The expected value

obtained

The actual value

Returns:

Success iff obtained approximately equals expected +- delta. Failure otherwise.

Deprecated
Inherited from:
HedgehogAssertions
@deprecated("Clues are unnecessary with hedgehog. Use HedgehogAssertions.diff, which will automatically output clues", "")
def assertNoDiff(obtained: String, expected: String, clue: => Any): Result

Asserts two strings are equal without outputting a diff.

Asserts two strings are equal without outputting a diff.

Analagous to munit.Assertions.assertNoDiff.

Value parameters:
clue

Ignored -- usage triggers a deprecation warning

expected

The expected string

obtained

The actual string

Returns:

Success iff actual is obtained. Failure otherwise.

Deprecated
Inherited from:
HedgehogAssertions
@deprecated("Clues are unnecessary with hedgehog. Use HedgehogAssertions.assertNotEquals, which will automatically output clues", "")
def assertNotEquals[A, B](obtained: A, expected: B, clue: => Any)(implicit ev: A =:= B): Result

Asserts obtained is not equal to expected using ==.

Asserts obtained is not equal to expected using ==.

Analagous to munit.Assertions.notEquals.

Value parameters:
clue

Ignored -- Usage triggers a deprecation warning

ev

Evidence that obtained and expected are of the same type.

expected

The expected value

obtained

The actual value

Returns:

Success iff obtained != expected. Failure otherwise.

Deprecated
Inherited from:
HedgehogAssertions

Inherited fields

lazy val Success: Success

Alias for Result.Success

Alias for Result.Success

See also:

hedgehog.core.Result.Success

Inherited from:
HedgehogAssertions
val munitLines: Lines
Inherited from:
Assertions
final val munitTestsBuffer: ListBuffer[Test]
Inherited from:
FunSuite

Implicits

Inherited implicits

implicit def testOptionsFromString(name: String)(implicit loc: Location): TestOptions

Implicitly create a TestOptions given a test name. This allows writing test("name") { ... } even if test accepts a TestOptions

Implicitly create a TestOptions given a test name. This allows writing test("name") { ... } even if test accepts a TestOptions

Inherited from:
TestOptionsConversions