Search code examples
java-8functional-programmingvavr

Vavr property testing


Property checking feature is advertised in the latest Vavr documentation along with the following example of its usage:

Arbitrary<Integer> ints = Arbitrary.integer();

// square(int) >= 0: OK, passed 1000 tests.
Property.def("square(int) >= 0")
        .forAll(ints)
        .suchThat(i -> i * i >= 0)
        .check()
        .assertIsSatisfied();

However, as per the library's javadoc, neither Arbitrary generator nor Property type exist.

What am I missing, if any? Is the documentation up to date?


Solution

  • Turns out, the following vavr-test dependency was missing, which is not obvious from Vavr documentation:

    <dependency>
        <groupId>io.vavr</groupId>
        <artifactId>vavr-test</artifactId>
        <version>0.9.1</version>
    </dependency>