net.jqwik.testing.TestingFalsifier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jqwik-testing Show documentation
Show all versions of jqwik-testing Show documentation
Jqwik Testing support module
package net.jqwik.testing;
import java.util.function.*;
import org.apiguardian.api.*;
import org.opentest4j.*;
import net.jqwik.api.*;
import net.jqwik.api.lifecycle.*;
import static org.apiguardian.api.API.Status.*;
@API(status = EXPERIMENTAL, since = "1.4.0")
public interface TestingFalsifier extends Falsifier, Predicate {
static TestingFalsifier alwaysFalsify() {
return ignore -> false;
}
static TestingFalsifier falsifier(Predicate predicate) {
return predicate::test;
}
@Override
default TryExecutionResult execute(T parameters) {
try {
boolean result = this.test(parameters);
return result ? TryExecutionResult.satisfied() : TryExecutionResult.falsified(null);
} catch (TestAbortedException tea) {
return TryExecutionResult.invalid();
} catch (AssertionError | Exception e) {
return TryExecutionResult.falsified(e);
}
}
}