use of io.vavr.test.Arbitrary in project tutorials by eugenp.
the class PropertyBasedLongRunningUnitTest method givenArbitrarySeq_whenCheckThatEverySecondElementIsEqualToString_thenTestPass.
@Test
public void givenArbitrarySeq_whenCheckThatEverySecondElementIsEqualToString_thenTestPass() {
// given
Arbitrary<Integer> multiplesOf2 = Arbitrary.integer().filter(i -> i > 0).filter(i -> i % 2 == 0 && i % 5 != 0);
// when
CheckedFunction1<Integer, Boolean> mustEquals = i -> stringsSupplier().get(i).equals("DividedByTwoWithoutRemainder");
// then
CheckResult result = Property.def("Every second element must equal to DividedByTwoWithoutRemainder").forAll(multiplesOf2).suchThat(mustEquals).check(10_000, 100);
result.assertIsSatisfied();
}
Aggregations