Data-driven tests for which tuples contain null values cannot be executed, as the DataBasedShrinkablesGenerator is unable to retrieve a class when checking for compatibility.
@Data
fun fizzBuzzExamples() = listOf(
Tuple.of(null, null),
Tuple.of(1, "1"),
Tuple.of(3, "Fizz"),
Tuple.of(5, "Buzz"),
Tuple.of(15, "FizzBuzz")
)
@Property
@FromData("fizzBuzzExamples")
fun fizzBuzzWorks(@ForAll index: Int?, @ForAll result: String?) {
fizzBuzz(index) shouldBe result
}
java.lang.NullPointerException
at net.jqwik.engine.properties.DataBasedShrinkablesGenerator.checkCompatibility(DataBasedShrinkablesGenerator.java:45)
This can be sidestepped with the use of optionals, but this seems like unnecessary cruft and can hurt the readability of both the data and the property test.
Suggested Solution
DataBasedShrinkablesGenerator should handle the case of a null tuple entry without throwing a Null Pointer Exception - instead of determining whether the valueType (which isn't defined) can be assigned to the parameterType, it could instead verify that the parameterType accepts null values. Perhaps the TypeUsage isn't even required for the value, and all values can be directly validated against the parameterType.
I'm not sure how such a solution would be realised, but I'm happy to have a deeper look.
Testing Problem
Data-driven tests for which tuples contain null values cannot be executed, as the DataBasedShrinkablesGenerator is unable to retrieve a class when checking for compatibility.
This can be sidestepped with the use of optionals, but this seems like unnecessary cruft and can hurt the readability of both the data and the property test.
Suggested Solution
DataBasedShrinkablesGenerator
should handle the case of anull
tuple entry without throwing a Null Pointer Exception - instead of determining whether thevalueType
(which isn't defined) can be assigned to theparameterType
, it could instead verify that theparameterType
accepts null values. Perhaps theTypeUsage
isn't even required for the value, and all values can be directly validated against theparameterType
.I'm not sure how such a solution would be realised, but I'm happy to have a deeper look.