All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jqwik.testing.TestingFalsifier Maven / Gradle / Ivy

The newest version!
package net.jqwik.testing;

import java.util.function.*;

import org.apiguardian.api.*;
import org.jspecify.annotations.*;
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);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy