Testing Problem
In Kotlin we want to express something like this:
@Property
fun myTest(@ForAll bigDecimals : List<BigDecimal>) {...}
which is (almost) the equivalent to the following Java code:
@Property
void myTest(@ForAll List<BigDecimal> bigDecimals) {...}
What looks easy and works out of the box with Java produces a net.jqwik.api.CannotFindArbitraryException: Cannot find an Arbitrary for Parameter of type [@net.jqwik.api.ForAll(value=) List<? extends BigDecimal>] with Kotlin.
The difference is obviously the type signature which for Java is List<BigDecimal> while it is List<? extends BigDecimal> for Kotlin.
Due to this little difference, the BigDecimalArbitraryProvider decides that he is unable to provide values for the given targetType.
Suggested Solution
The BigDecimalArbitraryProvider could use the more forgivingtargetType.isAssignableFrom(BigDecimal.class) instead of the stricter targetType.isOfType(BigDecimal.class) to determine if he is able to provide the requested values.
The same applies to some of the other *ArbitraryProviders.
Interestingly, currently not all *ArbitraryProviders are structured the same.
While the providers for BigDecimal and BigInteger use isOfType(...) others (like Boolean, Integer, ...) use isAssignableFrom(...).
Discussion
We tried to get around this by creating our own provider for BigDecimals, but experienced problems in the aftermath when we had trouble to let our provider correctly work with jqwik constraint annotations (like @bigrange). Probably we are missing some knowledge here . . .
Testing Problem
In Kotlin we want to express something like this:
which is (almost) the equivalent to the following Java code:
What looks easy and works out of the box with Java produces a
net.jqwik.api.CannotFindArbitraryException: Cannot find an Arbitrary for Parameter of type [@net.jqwik.api.ForAll(value=) List<? extends BigDecimal>]with Kotlin.The difference is obviously the type signature which for Java is
List<BigDecimal>while it isList<? extends BigDecimal>for Kotlin.Due to this little difference, the
BigDecimalArbitraryProviderdecides that he is unable to provide values for the given targetType.Suggested Solution
The
BigDecimalArbitraryProvidercould use the more forgivingtargetType.isAssignableFrom(BigDecimal.class)instead of the strictertargetType.isOfType(BigDecimal.class)to determine if he is able to provide the requested values.The same applies to some of the other
*ArbitraryProviders.Interestingly, currently not all
*ArbitraryProvidersare structured the same.While the providers for BigDecimal and BigInteger use
isOfType(...)others (like Boolean, Integer, ...) useisAssignableFrom(...).Discussion
We tried to get around this by creating our own provider for BigDecimals, but experienced problems in the aftermath when we had trouble to let our provider correctly work with jqwik constraint annotations (like @bigrange). Probably we are missing some knowledge here . . .