You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Other than Jqwik 1, which went with a JUnit Platform engine from day one, Jqwik 2's core will consist of a plain programming API for specifying and validating properties. The engine will be tackled in a different module.
API Suggestion
Simple Property Check
The simples invariant is if the code under test returns true (valid) or false (invalid):
PropertyDescriptionproperty =
PropertyDescription.property()
.forAll(Numbers.integers().between(0, 100))
.check(i -> i >= 0 && i <= 100);
PropertyValidatorvalidator = PropertyValidator.forProperty(property);
PropertyValidationResultresult = validator.validate();
Simple Property Assertions
Alternatively invariants can be formulated by standard assertions, e.g. through AssertJ:
Validation could automatically start with the check(..) or verify(..) method,
thereby saving the user the effort of creating a validator object and running validate(..).
This would be closer to how other PBT libraries do it.
It would, however, make two things more difficult:
Getting hold of the object describing the property
Applying different validation strategies
A convenience method like validateAtOnce(..) could be added later to make the simplest case simpler.
Why not Calling the interface PropertyDescription just Property
Property is the name for the Jqwik 1 main annotation.
I'd like to keep the name available for Jqwik 2's engine annotations without having to rely on package names.
Why not using an additional spec method for Assumptions?
Assume.that(..) will throw a TestAbortedException.
This approach allows to fail an assumption at any time during property validation.
Moreover, an additional assume(..) method when building the property description would have to get the
same parameters as the check or verify method, leading to unnecessary code duplication.
Open Questions
Would PropertySpecification be a more exact name than PropertyDescription?
Instead of having a validateStatistically(..) method there could be a StatisticalValidator type.
Instead of starting a fluent API with PropertyDescription.property() there could be an explicit property builder class.
The text was updated successfully, but these errors were encountered:
Other than Jqwik 1, which went with a JUnit Platform engine from day one, Jqwik 2's core will consist of a plain programming API for specifying and validating properties. The engine will be tackled in a different module.
API Suggestion
Simple Property Check
The simples invariant is if the code under test returns true (valid) or false (invalid):
Simple Property Assertions
Alternatively invariants can be formulated by standard assertions, e.g. through AssertJ:
Property Validation with different validation Strategy
The strategy to validate a given property can vary a lot and across different axes.
Some examples of variation:
Property Description with Additional Assumption
Some preconditions cannot be put into the arbitraries and require a value-spanning assumption.
Statistical Validation
Statistical validation is crucial when dealing with not fully deterministic algorithms;
ML classification is a typical example.
Rationale(s)
Split property description from validation
Validation could automatically start with the
check(..)
orverify(..)
method,thereby saving the user the effort of creating a validator object and running
validate(..)
.This would be closer to how other PBT libraries do it.
It would, however, make two things more difficult:
A convenience method like
validateAtOnce(..)
could be added later to make the simplest case simpler.Why not Calling the interface
PropertyDescription
justProperty
Property
is the name for the Jqwik 1 main annotation.I'd like to keep the name available for Jqwik 2's engine annotations without having to rely on package names.
Why not using an additional spec method for Assumptions?
Assume.that(..)
will throw aTestAbortedException
.This approach allows to fail an assumption at any time during property validation.
Moreover, an additional
assume(..)
method when building the property description would have to get thesame parameters as the
check
orverify
method, leading to unnecessary code duplication.Open Questions
PropertySpecification
be a more exact name thanPropertyDescription
?validateStatistically(..)
method there could be aStatisticalValidator
type.PropertyDescription.property()
there could be an explicit property builder class.The text was updated successfully, but these errors were encountered: